I have a problem with compiling boost.bimap library. My test program is a blank main function and only one include directive(like #include <boost/bimap.hpp>
).
After some investigations I found out that preprocessor had made some interesting constructions from header file like:
struct A { struct B{}; struct B; };
I don't know if this is correct or not, but gcc accepts it while clang and icc don't. Who is right and what can I do to compile programs with bimap library? Unfortunately, I can't use gcc in this case.
struct B{};
defines a nested class, thenstruct B;
is a re-declaration of the same nested class.GCC is wrong to accept the code (bug report), because the standard says in [class.mem]:
In your case the nested class is defined then declared, which is not allowed, so Clang and ICC are correct to give a diagnostic. However, when I test it they only give a warning, not an error, so maybe you are using
-Werror
, in which case stop doing that and the code should compile.The problem in the Boost.Bimap code is a known bug.