[libc++] incomplete type 'std::__1::ios_base'

Hi,

I’ve got the following compilation error while attempting to build boost-1.47.0 with ‘clang++ -stdlib=libc++’:


common.mkdir …/bin.v2/libs/wave
common.mkdir …/bin.v2/libs/wave/build
common.mkdir …/bin.v2/libs/wave/build/clang-linux-3.0
common.mkdir …/bin.v2/libs/wave/build/clang-linux-3.0/release
common.mkdir …/bin.v2/libs/wave/build/clang-linux-3.0/release/link-static
common.mkdir …/bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi
common.mkdir …/bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on
compile.c++.without-pth …/bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_exprgrammar.o
In file included from …/libs/wave/src/instantiate_cpp_exprgrammar.cpp:14:
In file included from …/boost/wave/wave_config.hpp:229:
…/boost/wave/util/flex_string.hpp:2573:34: error: incomplete type ‘std::__1::ios_base’ named in nested name specifier
is.setstate(std::ios_base::eofbit);

/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
In file included from ../libs/wave/src/instantiate_cpp_exprgrammar.cpp:14:
In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2589:26: error: incomplete type 'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::failbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
2 errors generated.

"clang++" -c -x c++ -stdlib=libc++ -march=native -O3 -finline-functions -Wno-inline -Wall -pthread -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_USE_LIB=1 -DBOOST_WAVE_SUPPORT_THREADING=0 -DNDEBUG -I".." -o "../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_exprgrammar.o" "../libs/wave/src/instantiate_cpp_exprgrammar.cpp"

...failed compile.c++.without-pth ../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_exprgrammar.o...
compile.c++.without-pth ../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_grammar.o
In file included from ../libs/wave/src/instantiate_cpp_grammar.cpp:14:
In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2573:34: error: incomplete type 'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::eofbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
In file included from ../libs/wave/src/instantiate_cpp_grammar.cpp:14:
In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2589:26: error: incomplete type 'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::failbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
2 errors generated.

"clang++" -c -x c++ -stdlib=libc++ -march=native -O3 -finline-functions -Wno-inline -Wall -pthread -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_USE_LIB=1 -DBOOST_WAVE_SUPPORT_THREADING=0 -DNDEBUG -I".." -o "../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_grammar.o" "../libs/wave/src/instantiate_cpp_grammar.cpp"

...failed compile.c++.without-pth ../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_grammar.o...
compile.c++.without-pth ../bin.v2/libs/wave/build/clang-linux-3.0/release/link-static/threading-multi/wavetool-on/instantiate_cpp_literalgrs.o
In file included from ../libs/wave/src/instantiate_cpp_literalgrs.cpp:14:
In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2573:34: error: incomplete type 'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::eofbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
In file included from ../libs/wave/src/instantiate_cpp_literalgrs.cpp:14:
In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2589:26: error: incomplete type 'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::failbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of 'std::__1::ios_base'
class ios_base;
^
2 errors generated.

and on and on...

Is this a bug in libc++ or something wrong with boost itself?
Any comments will be greatly appreciated.

Thanks!

Ryuta

I've got the following compilation error while attempting to build
boost-1.47.0 with 'clang++ -stdlib=libc++':

[...]

In file included from ../boost/wave/wave_config.hpp:229:
../boost/wave/util/flex_string.hpp:2573:34: error: incomplete type
'std::__1::ios_base' named in nested name specifier
is.setstate(std::ios_base::eofbit);
~~~~~^~~~~~~~~~
/usr/include/c++/v1/iosfwd:95:7: note: forward declaration of
'std::__1::ios_base'
class ios_base;
^

Is this a bug in libc++ or something wrong with boost itself?

With boost I'd say. It looks like:

#if defined(__PATHSCALE__)
   #include <ios>
#else
   #include <iosfwd>
#endif

but ios_base is in <ios> so that one should be included always.

Hi Marc,

Just as you pointed out, it was boost’s fault. Patching flex_string.hpp like

— ./boost/wave/util/flex_string.hpp.orig 2011-09-10 18:15:29.916482429 +
0900
+++ ./boost/wave/util/flex_string.hpp 2011-09-10 18:18:58.687781264 +0900
@@ -103,7 +103,7 @@
#include
#include

-#if defined(PATHSCALE)
+#if defined(PATHSCALE) || defined(clang)
#include
#else
#include

fixed the problem, though I still have other boost issues.
Anyway, thanks for the tip! I appreciate it.

Regards,

Ryuta

Filed boost bug report:

https://svn.boost.org/trac/boost/ticket/5887

Thanks Ryuta and Marc!

Howard