From: Jonathan Wakely Date: Thu, 10 May 2018 19:27:14 +0000 (+0100) Subject: Document Dual ABI for std::ios_base::failure X-Git-Tag: releases/gcc-6.5.0~333 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4b4908ded84973b0834b5624be25de31a8ad445;p=thirdparty%2Fgcc.git Document Dual ABI for std::ios_base::failure * doc/xml/manual/debug_mode.xml: Add array and forward_list to list of C++11 containers with Debug Mode support. * doc/xml/manual/using.xml: Document Dual ABI for ios_base::failure. * doc/html/*: Regenerate. From-SVN: r260132 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c6ae45be6332..b003c5951e3c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2018-05-10 Jonathan Wakely + + * doc/xml/manual/debug_mode.xml: Add array and forward_list to list + of C++11 containers with Debug Mode support. + * doc/xml/manual/using.xml: Document Dual ABI for ios_base::failure. + * doc/html/*: Regenerate. + 2018-05-03 Jonathan Wakely PR libstdc++/85632 use uintmax_t for arithmetic diff --git a/libstdc++-v3/doc/html/manual/debug_mode_using.html b/libstdc++-v3/doc/html/manual/debug_mode_using.html index 99142903dfb5..e4f7ea54d226 100644 --- a/libstdc++-v3/doc/html/manual/debug_mode_using.html +++ b/libstdc++-v3/doc/html/manual/debug_mode_using.html @@ -20,4 +20,4 @@ containers:

Table 17.1. Debugging Containers

ContainerHeaderDebug containerDebug header
std::bitsetbitset__gnu_debug::bitset<debug/bitset>
std::dequedeque__gnu_debug::deque<debug/deque>
std::listlist__gnu_debug::list<debug/list>
std::mapmap__gnu_debug::map<debug/map>
std::multimapmap__gnu_debug::multimap<debug/map>
std::multisetset__gnu_debug::multiset<debug/set>
std::setset__gnu_debug::set<debug/set>
std::stringstring__gnu_debug::string<debug/string>
std::wstringstring__gnu_debug::wstring<debug/string>
std::basic_stringstring__gnu_debug::basic_string<debug/string>
std::vectorvector__gnu_debug::vector<debug/vector>

In addition, when compiling in C++11 mode, these additional containers have additional debug capability. -

Table 17.2. Debugging Containers C++11

ContainerHeaderDebug containerDebug header
std::unordered_mapunordered_map__gnu_debug::unordered_map<debug/unordered_map>
std::unordered_multimapunordered_map__gnu_debug::unordered_multimap<debug/unordered_map>
std::unordered_setunordered_set__gnu_debug::unordered_set<debug/unordered_set>
std::unordered_multisetunordered_set__gnu_debug::unordered_multiset<debug/unordered_set>

\ No newline at end of file +

Table 17.2. Debugging Containers C++11

ContainerHeaderDebug containerDebug header
std::arrayarray__gnu_debug::array<debug/array>
std::forward_listforward_list__gnu_debug::forward_list<debug/forward_list>
std::unordered_mapunordered_map__gnu_debug::unordered_map<debug/unordered_map>
std::unordered_multimapunordered_map__gnu_debug::unordered_multimap<debug/unordered_map>
std::unordered_setunordered_set__gnu_debug::unordered_set<debug/unordered_set>
std::unordered_multisetunordered_set__gnu_debug::unordered_multiset<debug/unordered_set>

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/using_dual_abi.html b/libstdc++-v3/doc/html/manual/using_dual_abi.html index 4a62c0267be7..916ac575f64b 100644 --- a/libstdc++-v3/doc/html/manual/using_dual_abi.html +++ b/libstdc++-v3/doc/html/manual/using_dual_abi.html @@ -14,7 +14,7 @@ for the new implementations have different names the definitions for both versions can be present in the same library.

The _GLIBCXX_USE_CXX11_ABI macro (see -Macros) controls whether + Macros) controls whether the declarations in the library headers use the old or new ABI. So the decision of which ABI to use can be made separately for each source file being compiled. @@ -43,10 +43,35 @@ facet that derives from one or other version of time_get is installed in the locale).

Although the standard exception types defined in - <stdexcept> use strings, they + <stdexcept> use strings, most are not defined twice, so that a std::out_of_range exception thrown in one file can always be caught by a suitable handler in another file, even if the two files are compiled with different ABIs. +

One exception type does change when using the new ABI, namely + std::ios_base::failure. + This is necessary because the 2011 standard changed its base class from + std::exception to + std::system_error, which causes its layout to change. + Exceptions due to iostream errors are thrown by a function inside + libstdc++.so, so whether the thrown + exception uses the old std::ios_base::failure type + or the new one depends on the ABI that was active when + libstdc++.so was built, + not the ABI active in the user code that is using + iostreams. + This means that for a given build of GCC the type thrown is fixed. + In current releases the library throws a special type that can be caught + by handlers for either the old or new type, + but for GCC 7.1, 7.2 and 7.3 the library throws the new + std::ios_base::failure type, + and for GCC 5.x and 6.x the library throws the old type. + Catch handlers of type std::ios_base::failure + will only catch the exceptions if using a newer release, + or if the handler is compiled with the same ABI as the type thrown by + the library. + Handlers for std::exception will always catch + iostreams exceptions, because the old and new type both inherit from + std::exception.

Troubleshooting

If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to diff --git a/libstdc++-v3/doc/xml/manual/debug_mode.xml b/libstdc++-v3/doc/xml/manual/debug_mode.xml index 8b5380dfeec9..d883de642be7 100644 --- a/libstdc++-v3/doc/xml/manual/debug_mode.xml +++ b/libstdc++-v3/doc/xml/manual/debug_mode.xml @@ -285,7 +285,19 @@ containers have additional debug capability. - + + std::array + array + __gnu_debug::array + <debug/array> + + + std::forward_list + forward_list + __gnu_debug::forward_list + <debug/forward_list> + + std::unordered_map unordered_map __gnu_debug::unordered_map diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 007bb8e5fa20..6822655119eb 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -999,7 +999,7 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe The _GLIBCXX_USE_CXX11_ABI macro (see -) controls whether + ) controls whether the declarations in the library headers use the old or new ABI. So the decision of which ABI to use can be made separately for each source file being compiled. @@ -1034,12 +1034,39 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe Although the standard exception types defined in - <stdexcept> use strings, they + <stdexcept> use strings, most are not defined twice, so that a std::out_of_range exception thrown in one file can always be caught by a suitable handler in another file, even if the two files are compiled with different ABIs. + One exception type does change when using the new ABI, namely + std::ios_base::failure. + This is necessary because the 2011 standard changed its base class from + std::exception to + std::system_error, which causes its layout to change. + Exceptions due to iostream errors are thrown by a function inside + libstdc++.so, so whether the thrown + exception uses the old std::ios_base::failure type + or the new one depends on the ABI that was active when + libstdc++.so was built, + not the ABI active in the user code that is using + iostreams. + This means that for a given build of GCC the type thrown is fixed. + In current releases the library throws a special type that can be caught + by handlers for either the old or new type, + but for GCC 7.1, 7.2 and 7.3 the library throws the new + std::ios_base::failure type, + and for GCC 5.x and 6.x the library throws the old type. + Catch handlers of type std::ios_base::failure + will only catch the exceptions if using a newer release, + or if the handler is compiled with the same ABI as the type thrown by + the library. + Handlers for std::exception will always catch + iostreams exceptions, because the old and new type both inherit from + std::exception. + +

Troubleshooting If you get linker errors about undefined references to symbols