On Tue, 19 Jul 2022 at 11:08, Jonathan Wakely wrote: > > On Sun, 17 Jul 2022 at 22:13, Stephan Bergmann via Libstdc++ > <libstd...@gcc.gnu.org> wrote: > > > > On 7/15/22 22:25, Marek Polacek via Gcc-patches wrote: > > > Yeah, I guess so. But I've already pushed the patch. > > > > This commit obviously breaks using libstdc++ with Clang (in -std=c++2b > > mode), which doesn't implement those new builtins. Something like the > > below would fix that, > > Thanks, Stephan, I'll fix this.
This patch doesn't work, because __has_builtin doesn't detect the new built-ins. I have a patch that solves that, so we can make the change to the library headers. > > > > > > diff --git a/libstdc++-v3/include/std/type_traits > > > b/libstdc++-v3/include/std/type_traits > > > index b1a1deecf66..a6e028b42ec 100644 > > > --- a/libstdc++-v3/include/std/type_traits > > > +++ b/libstdc++-v3/include/std/type_traits > > > @@ -3505,6 +3505,7 @@ template<typename _Ret, typename _Fn, typename... > > > _Args> > > > template<typename _Tp> > > > inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; > > > > > > +#if __has_builtin(__reference_constructs_from_temporary) && > > > __has_builtin(__reference_converts_from_temporary) > > > #define __cpp_lib_reference_from_temporary 202202L > > > > > > /// True if _Tp is a reference type, a _Up value can be bound to _Tp in > > > @@ -3544,6 +3545,7 @@ template<typename _Ret, typename _Fn, typename... > > > _Args> > > > template<typename _Tp, typename _Up> > > > inline constexpr bool reference_converts_from_temporary_v > > > = reference_converts_from_temporary<_Tp, _Up>::value; > > > +#endif > > > #endif // C++23 > > > > > > #if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED > > > diff --git a/libstdc++-v3/include/std/version > > > b/libstdc++-v3/include/std/version > > > index 5edca2f3007..7c4b7f7cc6d 100644 > > > --- a/libstdc++-v3/include/std/version > > > +++ b/libstdc++-v3/include/std/version > > > @@ -304,7 +304,9 @@ > > > #define __cpp_lib_byteswap 202110L > > > #define __cpp_lib_constexpr_typeinfo 202106L > > > #define __cpp_lib_is_scoped_enum 202011L > > > +#if __has_builtin(__reference_constructs_from_temporary) && > > > __has_builtin(__reference_converts_from_temporary) > > > #define __cpp_lib_reference_from_temporary 202202L > > > +#endif > > > > > > #if _GLIBCXX_HOSTED > > > #define __cpp_lib_adaptor_iterator_pair_constructor 202106L > >