Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
On 13 April 2018 at 11:22, Jakub Jelinek wrote: > On Fri, Apr 13, 2018 at 11:19:35AM +0100, Jonathan Wakely wrote: >> --- a/libstdc++-v3/src/c++11/Makefile.am >> +++ b/libstdc++-v3/src/c++11/Makefile.am >> @@ -128,10 +128,7 @@ hashtable_c++0x.o: hashtable_c++0x.cc >> >> if ENABLE_DUAL_ABI >> # Rewrite the type info for __ios_failure. >> -rewrite_ios_failure_typeinfo = sed -e '/^_ZTISt13__ios_failure:$$/{' \ >> - -e 'n' \ >> - -e >> 's/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' \ >> - -e '}' >> +rewrite_ios_failure_typeinfo = sed -e >> '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' > > I miss / in between , and _ZTVN10__cxxabiv120__si_class_type_infoE > > $ echo | sed -e > '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_info_ZTVSt19__iosfail_type_info/' > sed: -e expression #1, char 29: unexpected `,' > $ echo | sed -e > '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' > > Jakub Not sure how that got past my testing, so I've made sure to test with a clean build this time. Committed to trunk and gcc-7-branch. commit 6b12637ba78f29a2a697d3fb78e3e23076d8dee4 Author: Jonathan WakelyDate: Fri Apr 13 11:30:48 2018 +0100 Fix broken sed command from previous commit * src/c++11/Makefile.am: Fix sed command. * src/c++11/Makefile.in: Regenerate. diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 12bc004a2ea..cdc49bb7f9b 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -128,7 +128,7 @@ hashtable_c++0x.o: hashtable_c++0x.cc if ENABLE_DUAL_ABI # Rewrite the type info for __ios_failure. -rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' +rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' cxx11-ios_failure-lt.s: cxx11-ios_failure.cc $(LTCXXCOMPILE) -S $< -o tmp-cxx11-ios_failure-lt.s
Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
On Fri, Apr 13, 2018 at 11:19:35AM +0100, Jonathan Wakely wrote: > --- a/libstdc++-v3/src/c++11/Makefile.am > +++ b/libstdc++-v3/src/c++11/Makefile.am > @@ -128,10 +128,7 @@ hashtable_c++0x.o: hashtable_c++0x.cc > > if ENABLE_DUAL_ABI > # Rewrite the type info for __ios_failure. > -rewrite_ios_failure_typeinfo = sed -e '/^_ZTISt13__ios_failure:$$/{' \ > - -e 'n' \ > - -e > 's/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' \ > - -e '}' > +rewrite_ios_failure_typeinfo = sed -e > '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' I miss / in between , and _ZTVN10__cxxabiv120__si_class_type_infoE $ echo | sed -e '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_info_ZTVSt19__iosfail_type_info/' sed: -e expression #1, char 29: unexpected `,' $ echo | sed -e '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' Jakub
Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
Darwin has double underscores at the start of mangled names, so this fixes the sed command to be more flexible. Committed to trunk and gcc-7-branch. commit f80944837b4c21016d826bff5f497ceda85b9894 Author: Jonathan WakelyDate: Fri Apr 13 10:44:08 2018 +0100 Fix __iosfail_type_info hack to work on darwin * src/c++11/Makefile.am: Rewrite sed rule to be less fragile and to handle mangled names starting with double underscores on darwin. * src/c++11/Makefile.in: Regenerate. diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 8d524b67232..12bc004a2ea 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -128,10 +128,7 @@ hashtable_c++0x.o: hashtable_c++0x.cc if ENABLE_DUAL_ABI # Rewrite the type info for __ios_failure. -rewrite_ios_failure_typeinfo = sed -e '/^_ZTISt13__ios_failure:$$/{' \ - -e 'n' \ - -e 's/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' \ - -e '}' +rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' cxx11-ios_failure-lt.s: cxx11-ios_failure.cc $(LTCXXCOMPILE) -S $< -o tmp-cxx11-ios_failure-lt.s
Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
This fixes some comments with misspelled files and classes. Committed to trunk and gcc-7-branch. It occurred to me that the name of the new __ios_failure type is visible in the verbose terminate handler messages: terminate called after throwing an instance of 'std::__ios_failure' what(): basic_filebuf::underflow error reading the file: Is a directory Aborted (core dumped) And that there's no need for this type to use a reserved name. Users can't refer to it, or define macros that affect it (because it's never exposed in headers). So we could call it something else, like std::ios_failure rather than std::__ios_failure. Anybody got a preference they want to argue for? commit a28bcba2a812d4eac6da8ce86907b670361a09a6 Author: Jonathan WakelyDate: Thu Apr 12 21:28:38 2018 +0100 Fix comments that misspell names of files and classes * src/c++11/Makefile.am: Fix comment. * src/c++11/Makefile.in: Regenerate. * src/c++11/cxx11-ios_failure.cc: Fix comment. * src/c++98/ios_failure.cc: Likewise. diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 6f49f0d55d3..8d524b67232 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -127,7 +127,7 @@ hashtable_c++0x.o: hashtable_c++0x.cc $(CXXCOMPILE) -fimplicit-templates -c $< if ENABLE_DUAL_ABI -# Rewrite the type info for __dual_abi_ios_failure. +# Rewrite the type info for __ios_failure. rewrite_ios_failure_typeinfo = sed -e '/^_ZTISt13__ios_failure:$$/{' \ -e 'n' \ -e 's/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' \ diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc index 847b5946234..b1e4bfb2b44 100644 --- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc +++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc @@ -140,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __ios_failure can be upcast to the type in a catch handler. bool __iosfail_type_info::__do_upcast(const __class_type_info *dst_type, - void **obj_ptr) const + void **obj_ptr) const { // If the handler is for the gcc4-compatible ios::failure type then // catch the object stored in __ios_failure::buf instead of @@ -150,7 +150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION *obj_ptr = static_cast<__ios_failure*>(*obj_ptr)->buf; return true; } -// Otherwise proceeed as normal to see if the handler matches. +// Otherwise proceed as normal to see if the handler matches. return __class_type_info::__do_upcast(dst_type, obj_ptr); } #else // ! __cpp_rtti diff --git a/libstdc++-v3/src/c++98/ios_failure.cc b/libstdc++-v3/src/c++98/ios_failure.cc index a2fc5593e15..49d24f49620 100644 --- a/libstdc++-v3/src/c++98/ios_failure.cc +++ b/libstdc++-v3/src/c++98/ios_failure.cc @@ -57,7 +57,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _GLIBCXX_USE_DUAL_ABI // When the dual ABI is enabled __throw_ios_failure() is defined in - // src/c++11/ios_failure.cc + // src/c++11/cxx11-ios_failure.cc #if __cpp_rtti // If RTTI is enabled the exception type thrown will use these functions to // construct/destroy a gcc4-compatible ios::failure object in a buffer,
Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
On 10 April 2018 at 00:36, Jonathan Wakely wrote: > Define a new exception type derived from std::ios::failure[abi:cxx11] > which also aggregates an object of the gcc4-compatible ios::failure > type. Make __throw_ios_failure throw this new type for iostream errors > that raise exceptions. Provide custom type info for the new type so that > it can be caught by handlers for the gcc4-compatible ios::failure type > as well as handlers for ios::failure[abi:cxx11] and its bases. > > PR libstdc++/85222 > * src/c++11/Makefile.am [ENABLE_DUAL_ABI]: Add special rules for > cxx11-ios_failure.cc to rewrite type info for __ios_failure. > * src/c++11/Makefile.in: Regenerate. > * src/c++11/cxx11-ios_failure.cc (__ios_failure, __iosfail_type_info): > New types. > [_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. > * src/c++11/ios.cc (__throw_ios_failure): Remove definition. > * src/c++98/ios_failure.cc (__construct_ios_failure) > (__destroy_ios_failure, is_ios_failure_handler): New functions. > [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. > * testsuite/27_io/ios_base/failure/dual_abi.cc: New. > * testsuite/27_io/basic_ios/copyfmt/char/1.cc: Revert changes to > handler types, to always catch std::ios_base::failure. > * testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_arithmetic/char/ > exceptions_failbit.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/ > exceptions_failbit.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_other/char/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_other/wchar_t/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise. > * testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise. > * testsuite/27_io/basic_ostream/inserters_other/char/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ > exceptions_null.cc: Likewise. > * testsuite/27_io/ios_base/storage/2.cc: Likewise. > > Tested x86_64-linux and powerpc64-linux, with the default config, and > --disable-libstdcxx-dual-abi, and > --with-default-libstdcxx-abi=gcc4-compatible. I intend to commit this > to trunk and gcc-7-branch soon. This removes the #define for _GLIBCXX_USE_CXX11_ABI from the top of src/c++11/ios.cc, because __throw_ios_failure is no longer defined there. Tested as before, committed to trunk. commit 845d8dc521d0958b625f2bc691b284e221009929 Author: Jonathan WakelyDate: Wed Apr 11 13:47:31 2018 +0100 Remove #define made redundant by r259281 The definition of __throw_ios_failure is no longer in this file, so setting the macro here is unnecessary. * src/c++11/ios.cc: Remove redundant macro definition. diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index e928c594149..82063e4b2f5 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -26,10 +26,6 @@ // ISO C++ 14882: 27.4 Iostreams base classes // -// Determines the version of ios_base::failure thrown by __throw_ios_failure. -// If !_GLIBCXX_USE_DUAL_ABI this will get undefined automatically. -#define _GLIBCXX_USE_CXX11_ABI 1 - #include #include
Re: [PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
On Tue, 10 Apr 2018, Jonathan Wakely wrote: > Define a new exception type derived from std::ios::failure[abi:cxx11] > which also aggregates an object of the gcc4-compatible ios::failure > type. Make __throw_ios_failure throw this new type for iostream errors > that raise exceptions. Provide custom type info for the new type so that > it can be caught by handlers for the gcc4-compatible ios::failure type > as well as handlers for ios::failure[abi:cxx11] and its bases. > > PR libstdc++/85222 > * src/c++11/Makefile.am [ENABLE_DUAL_ABI]: Add special rules for > cxx11-ios_failure.cc to rewrite type info for __ios_failure. > * src/c++11/Makefile.in: Regenerate. > * src/c++11/cxx11-ios_failure.cc (__ios_failure, __iosfail_type_info): > New types. > [_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. > * src/c++11/ios.cc (__throw_ios_failure): Remove definition. > * src/c++98/ios_failure.cc (__construct_ios_failure) > (__destroy_ios_failure, is_ios_failure_handler): New functions. > [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. > * testsuite/27_io/ios_base/failure/dual_abi.cc: New. > * testsuite/27_io/basic_ios/copyfmt/char/1.cc: Revert changes to > handler types, to always catch std::ios_base::failure. > * testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_arithmetic/char/ > exceptions_failbit.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/ > exceptions_failbit.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_other/char/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_istream/extractors_other/wchar_t/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise. > * testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise. > * testsuite/27_io/basic_ostream/inserters_other/char/ > exceptions_null.cc: Likewise. > * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ > exceptions_null.cc: Likewise. > * testsuite/27_io/ios_base/storage/2.cc: Likewise. > > Tested x86_64-linux and powerpc64-linux, with the default config, and > --disable-libstdcxx-dual-abi, and > --with-default-libstdcxx-abi=gcc4-compatible. I intend to commit this > to trunk and gcc-7-branch soon. Thanks for working on this! Richard.
[PATCH] PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure
Define a new exception type derived from std::ios::failure[abi:cxx11] which also aggregates an object of the gcc4-compatible ios::failure type. Make __throw_ios_failure throw this new type for iostream errors that raise exceptions. Provide custom type info for the new type so that it can be caught by handlers for the gcc4-compatible ios::failure type as well as handlers for ios::failure[abi:cxx11] and its bases. PR libstdc++/85222 * src/c++11/Makefile.am [ENABLE_DUAL_ABI]: Add special rules for cxx11-ios_failure.cc to rewrite type info for __ios_failure. * src/c++11/Makefile.in: Regenerate. * src/c++11/cxx11-ios_failure.cc (__ios_failure, __iosfail_type_info): New types. [_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. * src/c++11/ios.cc (__throw_ios_failure): Remove definition. * src/c++98/ios_failure.cc (__construct_ios_failure) (__destroy_ios_failure, is_ios_failure_handler): New functions. [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. * testsuite/27_io/ios_base/failure/dual_abi.cc: New. * testsuite/27_io/basic_ios/copyfmt/char/1.cc: Revert changes to handler types, to always catch std::ios_base::failure. * testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_failbit.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/ exceptions_failbit.cc: Likewise. * testsuite/27_io/basic_istream/extractors_other/char/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_istream/extractors_other/wchar_t/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise. * testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ exceptions_null.cc: Likewise. * testsuite/27_io/ios_base/storage/2.cc: Likewise. Tested x86_64-linux and powerpc64-linux, with the default config, and --disable-libstdcxx-dual-abi, and --with-default-libstdcxx-abi=gcc4-compatible. I intend to commit this to trunk and gcc-7-branch soon. commit bdcc071eaa58aa07824b01a6da64662787abece7 Author: Jonathan WakelyDate: Tue Apr 10 00:19:25 2018 +0100 PR libstdc++/85222 allow catching iostream errors as gcc4-compatible ios::failure Define a new exception type derived from std::ios::failure[abi:cxx11] which also aggregates an object of the gcc4-compatible ios::failure type. Make __throw_ios_failure throw this new type for iostream errors that raise exceptions. Provide custom type info for the new type so that it can be caught by handlers for the gcc4-compatible ios::failure type as well as handlers for ios::failure[abi:cxx11] and its bases. PR libstdc++/85222 * src/c++11/Makefile.am [ENABLE_DUAL_ABI]: Add special rules for cxx11-ios_failure.cc to rewrite type info for __ios_failure. * src/c++11/Makefile.in: Regenerate. * src/c++11/cxx11-ios_failure.cc (__ios_failure, __iosfail_type_info): New types. [_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. * src/c++11/ios.cc (__throw_ios_failure): Remove definition. * src/c++98/ios_failure.cc (__construct_ios_failure) (__destroy_ios_failure, is_ios_failure_handler): New functions. [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. * testsuite/27_io/ios_base/failure/dual_abi.cc: New. * testsuite/27_io/basic_ios/copyfmt/char/1.cc: Revert changes to handler types, to always catch std::ios_base::failure. * testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_failbit.cc: Likewise. * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/ exceptions_failbit.cc: Likewise. * testsuite/27_io/basic_istream/extractors_other/char/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_istream/extractors_other/wchar_t/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise. * testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/ exceptions_null.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ exceptions_null.cc: Likewise. * testsuite/27_io/ios_base/storage/2.cc: Likewise. diff --git a/libstdc++-v3/src/c++11/Makefile.am