[PATCH] libstdc++: ifdef rtti specific function __throw_ios_failure() by __cpp_rtti

Jonathan Wakely jwakely@redhat.com
Fri Feb 12 10:30:37 GMT 2021


>Hello,
>
>ran into the following when building libstdc++ without rtti support:
>
>libstdc++-v3/src/c++11/cxx11-ios_failure.cc:174:54: error: no matching 
>function for call to 'std::ios_base::failure::failure(const char*&, int&)'
>
>Attached patch does as follows:

Libstdc++ patches need to be CC'd to the libstdc++@ list as well.

>ifdef rtti specific function __throw_ios_failure() by __cpp_rtti
>
>Overloaded __throw_ios_failure(const char*, int) got introduced in
>484e936e88e5, however __ios_failure() with respective signature is only
>defined if __cpp_rtti is defined, hence should only be used within
>contexts also guarded by __cpp_rtti.

This patch is wrong. If you simply disable that function definition
for !__cpp_rtti then you'll get linker errors from fstream.tcc when
that function is called.

/usr/bin/ld: /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `std::__throw_ios_failure(char const*, int)'

>This was done correctly for the c++98 part and probably just forgotten
>for c++11.

This has nothing to do with C++98, it's relted to the gcc4-compatible
ABI versus the cxx11 ABI.

I added a better patch to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99077

>Thanks
>
>   mirko
>
>PS: Shouldn't this have been covered by any tests?

Nobody tests building libstdc++ with -fno-rtti because almost nobody
does that.

But we have plenty of tests, and hundreds of them fail with your patch
:-)





More information about the Libstdc++ mailing list