Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2005-04-07 05:17:17


> Well, code like this doesn't trigger a warning when compiled with g++
>
> $ cat trial.cpp
> #include <cassert>
>
> int foo(bool a) {
> if (a)
> return 0;
> assert(false);
> }
>
> $ g++ -W -Wall -c trial.cpp
>
> Compare that with:
>
> $ g++ -DNDEBUG -W -Wall -c trial.cpp
> trial.cpp: In function `int foo(bool)':
> trial.cpp:7: warning: control reaches end of non-void function
>
> Clearly, the compiler is able to ascertain that execution won't proceed
> past the assert. It doesn't seem so unreasonable to hope that
> BOOST_STATIC_ASSERT would behave similarly.

The problem is that __attribute__((noreturn)) can only be applied to a
*function call which will never return*, a static assertion does not
generate a function call (indeed must not do so), so there is nothing to
which that attribute can be applied.

If you know differently then I'm all ears,

Regards,

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk