* [committed] libstdc++: Break header cycle between <new> and <exception>
@ 2020-09-02 13:15 Jonathan Wakely
2020-09-02 15:43 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2020-09-02 13:15 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Nathan Sidwell
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
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.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3625 bytes --]
commit 6bdbf0f37bda2587a4e82cbb956de7a159a397ae
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 2 13:27:57 2020
libstdc++: Break header cycle between <new> and <exception>
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.
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index f0cf4c55c09..da740e3732e 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -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;
}
}
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index ebd1c490282..21848a573d1 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -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() { }
diff --git a/libstdc++-v3/libsupc++/new_opvnt.cc b/libstdc++-v3/libsupc++/new_opvnt.cc
index 9f9dace5778..771696d4ba6 100644
--- a/libstdc++-v3/libsupc++/new_opvnt.cc
+++ b/libstdc++-v3/libsupc++/new_opvnt.cc
@@ -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
{
diff --git a/libstdc++-v3/testsuite/18_support/destroying_delete.cc b/libstdc++-v3/testsuite/18_support/destroying_delete.cc
index 96134d7e010..f0c9bb9fa25 100644
--- a/libstdc++-v3/testsuite/18_support/destroying_delete.cc
+++ b/libstdc++-v3/testsuite/18_support/destroying_delete.cc
@@ -19,6 +19,7 @@
// { dg-do run { target c++2a } }
#include <new>
+#include <type_traits>
#include <testsuite_hooks.h>
#ifndef __cpp_lib_destroying_delete
diff --git a/libstdc++-v3/testsuite/20_util/variant/index_type.cc b/libstdc++-v3/testsuite/20_util/variant/index_type.cc
index 73863fa677f..1c44758363c 100644
--- a/libstdc++-v3/testsuite/20_util/variant/index_type.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/index_type.cc
@@ -22,4 +22,4 @@
#include <variant>
static_assert(sizeof(std::variant<signed char, unsigned char>)
- < sizeof(size_t));
+ < sizeof(std::size_t));
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [committed] libstdc++: Break header cycle between <new> and <exception>
2020-09-02 13:15 [committed] libstdc++: Break header cycle between <new> and <exception> Jonathan Wakely
@ 2020-09-02 15:43 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-09-02 15:43 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]
On 02/09/20 14:15 +0100, Jonathan Wakely wrote:
>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.
>
>Tested powerpc64le-linux. Committed to trunk.
>
>commit 6bdbf0f37bda2587a4e82cbb956de7a159a397ae
>Author: Jonathan Wakely <jwakely@redhat.com>
>Date: Wed Sep 2 13:27:57 2020
>
> libstdc++: Break header cycle between <new> and <exception>
>
> 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.
>
>diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
>index f0cf4c55c09..da740e3732e 100644
>--- a/libstdc++-v3/include/bits/stl_iterator.h
>+++ b/libstdc++-v3/include/bits/stl_iterator.h
>@@ -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;
> }
>
> }
I've also changed the line above on the gcc-10 branch. Even though
both GCC and Clang accept it with -fno-exceptions (rather
mysteriously) it should be using the __throw_exception_again macro
instead.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 772 bytes --]
commit 7eb76b3b1721247bc2c9ab6a41c1655158ed3411
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 2 14:50:34 2020
libstdc++: Use __throw_exception_again macro for -fno-exceptions
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
Use __throw_exception_again macro.
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 19b1d53f781..d6bb085b3c6 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -2013,7 +2013,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return _M_current++;
} __catch(...) {
++_M_length;
- throw;
+ __throw_exception_again;
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-02 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 13:15 [committed] libstdc++: Break header cycle between <new> and <exception> Jonathan Wakely
2020-09-02 15:43 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).