This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch to detect invalid and missing ATTRIBUTE const/pure [take 2]


On Mon, Mar 25, 2002 at 12:46:01AM -0800, Richard Henderson wrote:
> On Mon, Mar 25, 2002 at 12:54:59AM -0500, Kaveh R. Ghazi wrote:
> >  > No.  const functions may be moved outside a loop, and if left 
> >  > inside the loop, may never be reached.
> [...]
> > 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?
> 
> No.  Like I just said, const functions may be called in
> cases that they weren't in the source code.

I agree with the person elsethread who observed that calling a
const/pure function more than the unoptimized program would have is
likely to be a mis-optimization; const and pure don't say anything
about the computational expense of the routine.  However, for safety's
sake, it is starting to sound like we need another attribute which
indicates a const/pure function that does not necessarily return, so
it cannot be called more times than the unoptimized program would have
(but less is safe).

__attribute__ ((const, maynotreturn)) ?

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]