This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to detect constant functions.
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: Re: Patch to detect constant functions.
- From: Richard Henderson <rth at cygnus dot com>
- Date: Wed, 18 Aug 1999 11:27:28 -0700
- Cc: law at cygnus dot com, gcc-patches at gcc dot gnu dot org
- References: <9908181102.AA29790@vlsi1.ultra.nyu.edu>
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~