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]

Re: Patch to detect constant functions.


On Wed, Aug 18, 1999 at 07:02:54AM -0400, Richard Kenner wrote:
> Agreed.  However, I would suggest enhancing it so it can work across files
> somewhat by adding an __attribute__ that a user can manually set.

We already have one -- __attribute__((const)).

> When compiling a function with that attribute, GCC would treat it as an
> assertion and give an error if it were false.

The user knows better than we.  It may be that the global memory
while not readonly, is constant after program initialization.
Similarly wrt calling functions like getpagesize or getpid, or
using asms to access weird processor registers.

Perhaps a warning would be interesting, but I think it would 
trigger rather more often than we'd like.  E.g. anything using
alpha-linux's pthreads implementation (pthread_self).



r~


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