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: Compile time assertions for gcc


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>


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