This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Compile time assertions for gcc
- To: Andi Kleen <ak at suse dot de>
- Subject: Re: Compile time assertions for gcc
- From: David Howells <dhowells at cambridge dot redhat dot com>
- Date: Mon, 30 Apr 2001 14:51:56 +0100
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
Andi Kleen <ak@suse.de> wrote:
> I've not completed went through it, but your patch looks like you didn't
> turn off side effects for the argument expression.
I had one of the gcc engineers who work for Redhat/Cygnus (Andrey Haley) look
at it, and he said I should make sure it _did_ emit code in certain cases
(something to do with the possibility of having a volatile argument).
> Without it the assert wouldn't be a true nop.
After much wrangling here, it was decided that it should be written such that
it should return (condition_argument!=0).
This would allow you to change the assert macro from something like:
#define assert(X) if(X) ...
to something like:
#define assert(X) if(__builtin_ct_assertion(X,#X)) ...
David
PS: If you reply, can you check that the reply goes to
<dhowells@cambridge.redhat.com>, not <dhowells@warthog.cambridge.redhat.com>