gcc error message and Boost.static_assert
Vladimir Prus
ghost@cs.msu.su
Mon Apr 26 14:02:00 GMT 2004
Hello,
it appears that somewhere between 3.2 and 3.3 one of the error messages of gcc
was slightly changed, but that change makes one of the C++ Boost libraries
much less usable.
The library is Boost.static_assert and it the same as assert, only during
compile time. The docs are at:
http://www.boost.org/libs/static_assert/static_assert.htm
One of the uses is generating user-friendly error messages when template
classes are used in wrong way.
On the following program:
#include <boost/static_assert.hpp>
int main()
{
BOOST_STATIC_ASSERT(1 > 2);
return 0;
}
I get these error messages:
ghost@zigzag:/tmp$ g++-3.2 -I ~/Work/boost static_assert.cpp
static_assert.cpp: In function `int main()':
static_assert.cpp:6: `sizeof' applied to incomplete type `
boost::STATIC_ASSERTION_FAILURE<false>'
ghost@zigzag:/tmp$ g++-3.3 -I ~/Work/boost static_assert.cpp
static_assert.cpp: In function `int main()':
static_assert.cpp:6: error: invalid application of `sizeof' to an incomplete
type
ghost@zigzag:/tmp$ g++-3.4 -I ~/Work/boost static_assert.cpp
static_assert.cpp: In function `int main()':
static_assert.cpp:6: error: invalid application of `sizeof' to an incomplete
type
So, starting with 3.3 gcc does not include the name of the class when sizeof
is applied to incomplete type -- the trick static_assert uses. As the result,
instead of very visible STATIC_ASSERTION_FAILURE user gets regular error
message and need to look though all instantination to understand what's
wrong.
Do you think it's possible to put class name back in the error message, or
there's some other workaround?
Thanks in advance,
Volodya
More information about the Gcc
mailing list