public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-6439] libstdc++: Make std::variant work with Clang in C++20 mode [PR103891] Date: Tue, 11 Jan 2022 13:24:03 +0000 (GMT) [thread overview] Message-ID: <20220111132403.4A1AD38A940C@sourceware.org> (raw) https://gcc.gnu.org/g:5b417b35824fb5c15e3ee958cb86436b3409ebea commit r12-6439-g5b417b35824fb5c15e3ee958cb86436b3409ebea Author: Jonathan Wakely <jwakely@redhat.com> Date: Mon Jan 10 17:28:19 2022 +0000 libstdc++: Make std::variant work with Clang in C++20 mode [PR103891] Clang has some bugs with destructors that use constraints to be conditionally trivial, so disable the P2231R1 constexpr changes to std::variant unless the compiler is GCC 12 or later. If/when P2493R0 gets accepted and implemented by G++ we can remove the __GNUC__ check and use __cpp_concepts >= 202002 instead. libstdc++-v3/ChangeLog: PR libstdc++/103891 * include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS): Define. * include/std/variant (__cpp_lib_variant): Only define C++20 value when the compiler is known to support conditionally trivial destructors. * include/std/version (__cpp_lib_variant): Likewise. Diff: --- libstdc++-v3/include/bits/c++config | 5 +++++ libstdc++-v3/include/std/variant | 7 ++++--- libstdc++-v3/include/std/version | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index c64b61b3c90..b197349f976 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -810,6 +810,11 @@ namespace std #undef _GLIBCXX_HAS_BUILTIN +#if __cplusplus >= 202002L && __cpp_concepts && __GNUC__ >= 12 +// XXX workaround for missing feature test macro for P0848R3 (see P2493R0). +# define _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS 1 +#endif + // PSTL configuration #if __cplusplus >= 201703L diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index d74939eddc3..c41f9f27e00 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -44,9 +44,10 @@ #include <bits/stl_iterator_base_funcs.h> #include <bits/stl_construct.h> #include <bits/utility.h> // in_place_index_t -#if __cplusplus == 201703L +#ifndef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS # include <ext/aligned_buffer.h> -#else +#endif +#if __cplusplus >= 202002L # include <compare> #endif @@ -54,7 +55,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#if __cplusplus >= 202002L && __cpp_concepts +#ifdef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS // P2231R1 constexpr needs constexpr unions and constrained destructors. # define __cpp_lib_variant 202106L #else diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index f421056964e..012d78e3b6b 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -173,7 +173,8 @@ # define __cpp_lib_to_chars 201611L #endif #define __cpp_lib_unordered_map_try_emplace 201411 -#if __cplusplus == 201703L || ! __cpp_concepts // N.B. updated value in C++20 +#ifndef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS +// N.B. updated value in C++20 # define __cpp_lib_variant 202102L #endif #endif @@ -286,7 +287,7 @@ # endif #define __cpp_lib_to_address 201711L #define __cpp_lib_to_array 201907L -#if __cpp_concepts +#ifdef _GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS # define __cpp_lib_variant 202106L #endif #endif
reply other threads:[~2022-01-11 13:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220111132403.4A1AD38A940C@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).