[committed] libstdc++: Break header cycle between <new> and <exception>

Jonathan Wakely jwakely@redhat.com
Wed Sep 2 15:43:41 GMT 2020


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 772 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200902/c61c42bc/attachment.bin>


More information about the Gcc-patches mailing list