]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/85343 overload __throw_ios_failure to take errno
authorJonathan Wakely <jwakely@redhat.com>
Tue, 14 Aug 2018 12:09:57 +0000 (13:09 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 14 Aug 2018 12:09:57 +0000 (13:09 +0100)
[ios::failure] p2: "When throwing ios_base::failure exceptions,
implementations should provide values of ec that identify the specific
reason for the failure."

This adds a new overload of __throw_ios_failure that can be passed
errno, to store error_code(errno, system_category()) in the exception
object.

PR libstdc++/85343
* acinclude.m4 (libtool_VERSION): Bump version.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add new symbol version.
Export new symbol.
* configure: Regenerate.
* doc/xml/manual/abi.xml: Document new versions.
* include/bits/fstream.tcc (basic_filebuf<C, T>::underflow)
(basic_filebuf<C, T>::xsgetn): Pass errno to __throw_ios_failure.
* include/bits/functexcept.h (__throw_ios_failure(const char*, int)):
Declare new overload.
* src/c++11/cxx11-ios_failure.cc (__ios_failure): Add new constructor
and static member function.
(__throw_ios_failure(const char*, int)): Define.
* src/c++98/ios_failure.cc [!_GLIBCXX_USE_DUAL_ABI]
(__throw_ios_failure(const char*, int)): Define.
* testsuite/util/testsuite_abi.cc: Update known and latest versions.

From-SVN: r263535

libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/doc/xml/manual/abi.xml
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/functexcept.h
libstdc++-v3/src/c++11/cxx11-ios_failure.cc
libstdc++-v3/src/c++98/ios_failure.cc

index 65890ea4b6b4e8f3811b0ea4086ce7d8a245e251..55570c77bf2bf4bcf7f38c3889bba351137721e0 100644 (file)
@@ -1,3 +1,18 @@
+2018-08-14  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/85343
+       * config/abi/pre/gnu.ver: Export new symbol.
+       * doc/xml/manual/abi.xml: Document new versions.
+       * include/bits/fstream.tcc (basic_filebuf<C, T>::underflow)
+       (basic_filebuf<C, T>::xsgetn): Pass errno to __throw_ios_failure.
+       * include/bits/functexcept.h (__throw_ios_failure(const char*, int)):
+       Declare new overload.
+       * src/c++11/cxx11-ios_failure.cc (__ios_failure): Add new constructor
+       and static member function.
+       (__throw_ios_failure(const char*, int)): Define.
+       * src/c++98/ios_failure.cc [!_GLIBCXX_USE_DUAL_ABI]
+       (__throw_ios_failure(const char*, int)): Define.
+
 2018-08-14  Jeremy Sawicki  <jeremy-gcc@sawicki.us>
 
        * include/ext/rope (_Rope_iterator_base(const _Rope_iterator_base&))
index 593783da1aae11d1f9bda2f96892e317873f7bca..03b23200a1a181b220db69b2215245648acce1fb 100644 (file)
@@ -2046,6 +2046,9 @@ GLIBCXX_3.4.26 {
     _ZNSt3pmr25monotonic_buffer_resource13_M_new_bufferE[jmy][jmy];
     _ZNSt3pmr25monotonic_buffer_resource18_M_release_buffersEv;
 
+    # std::__throw_ios_failure(const char*, int);
+    _ZSt19__throw_ios_failurePKci;
+
 } GLIBCXX_3.4.25;
 
 # Symbols in the support library (libsupc++) have their own tag.
index 733c803ffacf826bfa2042fdbf4abb8040c7a1e8..8859e965000362bc1e294b20e958a5806b450907 100644 (file)
@@ -268,6 +268,7 @@ compatible.
     <listitem><para>GCC 7.1.0: libstdc++.so.6.0.23</para></listitem>
     <listitem><para>GCC 7.2.0: libstdc++.so.6.0.24</para></listitem>
     <listitem><para>GCC 8.0.0: libstdc++.so.6.0.25</para></listitem>
+    <listitem><para>GCC 9.0.0: libstdc++.so.6.0.26</para></listitem>
     </itemizedlist>
     <para>
       Note 1: Error should be libstdc++.so.3.0.3.
@@ -338,6 +339,7 @@ compatible.
     <listitem><para>GCC 7.1.0: GLIBCXX_3.4.23, CXXABI_1.3.11</para></listitem>
     <listitem><para>GCC 7.2.0: GLIBCXX_3.4.24, CXXABI_1.3.11</para></listitem>
     <listitem><para>GCC 8.0.0: GLIBCXX_3.4.25, CXXABI_1.3.11</para></listitem>
+    <listitem><para>GCC 9.0.0: GLIBCXX_3.4.26, CXXABI_1.3.11</para></listitem>
     </itemizedlist>
     </listitem>
 
index 6205db75340b0fdffb3a00dc649b088b35514685..ed98f13e0e0c1d1692ec999ffc17aa72dee4a495 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <bits/cxxabi_forced.h>
 #include <bits/move.h>   // for swap
+#include <cerrno>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -471,7 +472,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                "invalid byte sequence in file"));
          else
            __throw_ios_failure(__N("basic_filebuf::underflow "
-                               "error reading the file"));
+                               "error reading the file"), errno);
        }
       return __ret;
     }
@@ -717,7 +718,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), __n);
              if (__len == -1)
                __throw_ios_failure(__N("basic_filebuf::xsgetn "
-                                       "error reading the file"));
+                                       "error reading the file"), errno);
              if (__len == 0)
                break;
  
index 6f6ffc5ee3b930a22d1321779c3f392c5fc34d05..9d5acdb3b558ba0eb5a31fb90cc363ff68e2850a 100644 (file)
@@ -94,9 +94,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   void
   __throw_ios_failure(const char*) __attribute__((__noreturn__));
 
+  void
+  __throw_ios_failure(const char*, int) __attribute__((__noreturn__));
+
+  // Helpers for exception objects in <system_error>
   void
   __throw_system_error(int) __attribute__((__noreturn__));
 
+  // Helpers for exception objects in <future>
   void
   __throw_future_error(int) __attribute__((__noreturn__));
 
index b1e4bfb2b4444dea308f3426338e41f921d8226c..26816fae5707c22861ad2f08e69db4a57edc4ec7 100644 (file)
@@ -114,6 +114,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __ios_failure(const char* s) : failure(s)
     { __construct_ios_failure(buf, runtime_error::what()); }
 
+    __ios_failure(const char* s, int e) : failure(s, to_error_code(e))
+    { __construct_ios_failure(buf, runtime_error::what()); }
+
     ~__ios_failure()
     { __destroy_ios_failure(buf); }
 
@@ -122,6 +125,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // There are assertions in src/c++98/ios_failure.cc to ensure the size
     // and alignment assumptions are valid.
     alignas(runtime_error) unsigned char buf[sizeof(runtime_error)];
+
+    static error_code
+    to_error_code(int e)
+    { return e ? error_code(e, system_category()) : io_errc::stream; }
   };
 
   // Custom type info for __ios_failure.
@@ -161,5 +168,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_ios_failure(const char* __s __attribute__((unused)))
   { _GLIBCXX_THROW_OR_ABORT(__ios_failure(_(__s))); }
 
+  void
+  __throw_ios_failure(const char* str __attribute__((unused)),
+                     int err __attribute__((unused)))
+  { _GLIBCXX_THROW_OR_ABORT(__ios_failure(_(str), err)); }
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
index 49d24f49620e31bdee3ea42fd54859c32943f516..794124b68e74013ac85042d8da7a820ed97b9a98 100644 (file)
@@ -88,7 +88,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_ios_failure(const char* __s __attribute__((unused)))
   { _GLIBCXX_THROW_OR_ABORT(ios::failure(_(__s))); }
 
-#endif
+  void
+  __throw_ios_failure(const char* str, int)
+  { __throw_ios_failure(str); }
+
+#endif // _GLIBCXX_USE_DUAL_ABI
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace