[cfe-dev] CLang 2.1 doesn't catch assert within if
Don Quixote de la Mancha
quixote at dulcineatech.com
Fri Oct 7 22:23:02 PDT 2011
On Fri, Oct 7, 2011 at 10:16 PM, Charles Davis <cdavis at mymail.mines.edu> wrote:
>
> On Oct 7, 2011, at 11:02 PM, Don Quixote de la Mancha wrote:
>>
>> If NDEBUG is defined as for a release or profile build, you'll get the
>> following in your preprocessed code, which will be very hard to debug:
>>
>> if ( condition )
>> following_line();
> No it won't. It will look like this:
> if ( condition )
> (void)0;
>
> following_line();
>
> That's because, when NDEBUG is defined, assert(3) is defined like so:
>
> #define assert(cond) (void)0
You wrote that as "assert(3)" which suggests you are referring to a
UNIX man page. When I got bit in the ass by putting assert() in a
conditional, it was with Microsoft Visual C++ 7 or maybe 7.1.
Redefining assert() to (void)0 is clearly the right thing to do but I
am quite certain that whatever version of VC++ I was using didn't do
that, because a release build had definitely reproducible, subtly
different results than a debug build that got fixed when I put my
assert() in a Basic Block.
Besides NDEBUG, what other common preprocessor flags and compiler
settings are supposed to guarantee that the program's error-free does
not change?
Ever Faithful,
Don Quixote
--
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
quixote at dulcineatech.com
More information about the cfe-dev
mailing list