libstdc++: Break header cycle between <new> and <exception>
authorJonathan Wakely <jwakely@redhat.com>
Wed, 2 Sep 2020 12:27:57 +0000 (13:27 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 2 Sep 2020 12:56:32 +0000 (13:56 +0100)
The <new> and <exception> headers each include each other, which makes
building them as header-units "exciting". The <new> header only needs
the definition of std::exception (in order to derive from it) which is
already in its own header, so just include that.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h: Include <bits/exception_defines.h>
for definitions of __try, __catch and __throw_exception_again.
(counted_iterator::operator++(int)): Use __throw_exception_again
instead of throw.
* libsupc++/new: Include <bits/exception.h> not <exception>.
* libsupc++/new_opvnt.cc: Include <bits/exception_defines.h>.
* testsuite/18_support/destroying_delete.cc: Include
<type_traits> for std::is_same_v definition.
* testsuite/20_util/variant/index_type.cc: Qualify size_t.

libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/libsupc++/new
libstdc++-v3/libsupc++/new_opvnt.cc
libstdc++-v3/testsuite/18_support/destroying_delete.cc
libstdc++-v3/testsuite/20_util/variant/index_type.cc

index f0cf4c55c091df1959451773eb31337895655769..da740e3732e235f553b7193b693f0b97b28ab4d1 100644 (file)
@@ -79,6 +79,7 @@
 #if __cplusplus > 201703L
 # include <compare>
 # include <new>
+# include <bits/exception_defines.h>
 # include <bits/iterator_concepts.h>
 #endif
 
@@ -2062,7 +2063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            return _M_current++;
          } __catch(...) {
            ++_M_length;
-           throw;
+           __throw_exception_again;
          }
 
       }
index ebd1c490282a5c1fc351df5a4c74152f767561fb..21848a573d1c7165c327d92551a4402301c1538c 100644 (file)
@@ -38,7 +38,7 @@
 #pragma GCC system_header
 
 #include <bits/c++config.h>
-#include <exception>
+#include <bits/exception.h>
 
 #pragma GCC visibility push(default)
 
@@ -52,7 +52,7 @@ namespace std
    *
    *  @c bad_alloc (or classes derived from it) is used to report allocation
    *  errors from the throwing forms of @c new.  */
-  class bad_alloc : public exception 
+  class bad_alloc : public exception
   {
   public:
     bad_alloc() throw() { }
index 9f9dace577819637a7ac895755ff8f1f7b86ce0d..771696d4ba60b2c974cdb821cf77403e6c49144d 100644 (file)
@@ -25,7 +25,8 @@
 
 #include <bits/c++config.h>
 #include "new"
+#include "exception_defines.h"
+
 _GLIBCXX_WEAK_DEFINITION void*
 operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
 {
index 96134d7e010dc66a1d291eecb868b907d5d90cb6..f0c9bb9fa2532f2b47bcd8639e221c31b9ccf264 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <new>
+#include <type_traits>
 #include <testsuite_hooks.h>
 
 #ifndef __cpp_lib_destroying_delete
index 73863fa677f8cc66e3750c7dbc136e2630f71790..1c44758363cf0a015f2580e44d35f65b33878648 100644 (file)
@@ -22,4 +22,4 @@
 #include <variant>
 
 static_assert(sizeof(std::variant<signed char, unsigned char>)
-             < sizeof(size_t));
+             < sizeof(std::size_t));