https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88518

--- Comment #5 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Matthew Wilcox from comment #2)
> Thanks!  What I actually want to do is annotate g() to the effect that it
> reads the pointed-to variable before it writes it.  IOW, I want to write
> something like:
> 
> void g(unsigned long __attribute__((read_before_write)) *p);
> void h(void);
> 
> void f(void)
> {
>         unsigned long i;
> 
>         h();
>         g(&i);
> }
> 
> and have gcc emit a warning that i is used uninitialised.  I tried adding i
> = i prior to the call of g() through macro trickery, but was surprised that
> it didn't trigger, and simplified down to this test-case.
> 
> Any chance I could get that attribute or something like it?

The object access attributes that Martin Sebor added recently might work
somewhat along these lines, but I haven't actually tested yet...

Reply via email to