[RFC] Have assert macros

Nicholas Nethercote njn25@cam.ac.uk
Wed Aug 25 09:55:00 GMT 2004


On Wed, 25 Aug 2004, Nathan Sidwell wrote:

> Zack Weinberg wrote:
>> but I am undecided about whether these checks ought to be off in the
>> release builds.
>
> I'm not sure either, which is why I think the default should be to
> leave them on.

Leave them on!  I heartily recommend it;  we do that in Valgrind and it 
has saved us countless headaches -- it makes life so much easier when a 
user reports an assertion failure on a specified line, rather than a 
random crash or similar.

You do have to be a bit careful that it doesn't affect performance too 
much.  Generally assertions check pretty simple things, though.  You 
already have this issue with GCC's --enable-checking flag (or whatever 
it's called).

Balancing this is not always easy;  I'd recommend having a minimum level 
of checking always on, ie. all assertions and some basic sanity-checking 
of data structures.  Then have a command-line arg that asks for more 
thorough checking, which might be turned on for developers by default.

Just my two cents.

N



More information about the Gcc mailing list