http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56282
Bug #: 56282 Summary: [4.8 regression] std::basic_ios<char> broken with -std=c++11 (undefined reference) Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: dan...@constexpr.org Simple enough: $ echo -e '#include <iostream>\n int main() { std::cout << "Hello World!\\n"; return bool(std::cout); }' | g++-4.8.0-pre9999 -x c++ - -std=c++11 /tmp/cc4QaOVU.o: In function `main': :(.text+0x19): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator bool() const' collect2: error: ld returned 1 exit status Broken by this commit: http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9d8eb68081f898e225727d69da8212813f27e199 The offending commit adds the correct test operator for C++11: +#if __cplusplus >= 201103L + explicit operator bool() const + { return !this->fail(); } +#else operator void*() const { return this->fail() ? 0 : const_cast<basic_ios*>(this); } +#endif However, std::basic_ios<char> is explicitly instantiated in libstdc++.so (from basic_ios.tcc): #if _GLIBCXX_EXTERN_TEMPLATE extern template class basic_ios<char>; #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_ios<wchar_t>; #endif #endif So the gcc doesn't instantiate explicit operator bool for std::basic_ios<char> and instead tries to use the instantiation in libstdc++.so, which only has the operator void*. $ g++-4.8.0-pre9999 -v Using built-in specs. COLLECT_GCC=g++-4.8.0-pre9999 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.8.0_pre9999/work/gcc-4.8.0-9999/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-pre9999 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.0_pre9999' Thread model: posix gcc version 4.8.0-pre9999 20130211 (experimental) commit 37db34b1d053392f4d8899178a7f647bb70f400e (Gentoo 4.8.0_pre9999)