Boost logo

Boost :

Subject: Re: [boost] suggestion on assertion macros
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2010-03-16 03:25:21

On Tue, Mar 16, 2010 at 12:05 AM, Roland Bock <rbock_at_[hidden]> wrote:
> So maybe (I still want to get rid of those warnings without disabling them),
> it would be better to define a companion to assert, like this:
> #include <cassert>
> #ifdef NDEBUG
>  #define DEBUG_CODE(some_code)
> #else
>  #define DEBUG_CODE(some_code) some_code
> #endif
> int main()
> {
>  DEBUG_CODE(int i = 0;)
>  assert(i);
> }
> What do you think?

I think that the solution is to disable such warnings in release
builds. They serve no purpose other than to tell you that assert did
what it was supposed to do in release.

MSVC has a similar warning, the one that says "removed unreachable
code" which tells you that the optimizer deadstripped code that could
not be executed anyway. How would you deal with that warning, add
casts until the optimizer is sufficiently confused? :)

Emil Dotchevski
Reverge Studios, Inc.

Boost list run by bdawes at, gregod at, cpdaniel at, john at