Patch to detect invalid and missing ATTRIBUTE const/pure [take 2]
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sun Mar 24 21:55:00 GMT 2002
> From: Richard Henderson <rth@redhat.com>
>
> On Sun, Mar 24, 2002 at 08:30:23PM -0800, Zack Weinberg wrote:
> > I don't think failure to return invalidates const/pure-ness. If we
> > are considering moving or merging a call to a const/pure function, and
> > it is going to fail to return in one context, it is going to fail to
> > return in the other context too (or we wouldn't have done the
> > optimization at all). So the optimization remains safe: the program
> > still has the same semantics.
>
> No. const functions may be moved outside a loop, and if left
> inside the loop, may never be reached.
> r~
Ok so gcc never *suggests* marking functions calling a noreturn. Nor
does it implicitly mark static ones.
However given that the programmer may "know" that the noreturn call
never occurs in practice, does it make sense to bypass the warning
about the marking being "invalid" should the programmer decide to mark
it explicitly? (Again, consider whether we could mark functions in
light of tree/rtl checking and the noreturn calls to tree_check_failed
when such checks fail.)
--Kaveh
--
Kaveh R. Ghazi Director of Systems Architecture
ghazi@caip.rutgers.edu Qwest Global Services
More information about the Gcc-patches
mailing list