On Tue, Apr 29, 2025 at 11:05 AM Jonathan Wakely <[email protected]> wrote:
> Replace remaining uses of _GLIBCXX17_CONSTEXPR for constexpr-if, so that
> we always use constexpr-if in C++11 and C++14. Diagnostic pragmas are
> used to suppress diagnostics.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/char_traits.h (char_traits::assign): Use
> constexpr-if unconditionally for C++11 and C++14.
> * include/bits/locale_conv.h (__do_str_codecvt): Likewise.
> * include/bits/ostream.h (basic_ostream::_S_cast_flt): Likewise.
> * include/bits/random.tcc (shuffle_order_engine::operator())
> (seed_seq::seed_seq(Iter, Iter)): Likewise.
> * include/bits/shared_ptr_base.h (_Sp_counted_base::_M_release):
> Likewise.
> * include/bits/stl_tree.h (_Rb_tree::_M_move_data): Likewise.
> * include/bits/uniform_int_dist.h
> (uniform_int_distribution::operator()): Likewise.
> * include/bits/valarray_array.h (__valarray_default_construct)
> (__valarray_fill_construct, __valarray_copy_construct)
> (__valarray_copy_construct, __valarray_destroy_elements):
> Likewise.
> * include/experimental/numeric (lcm): Likewise.
> * include/std/bit (__rotl, __rotr, __countl_zero, __countr_zero)
> (__popcount, __bit_ceil) Likewise.:
> * include/std/bitset (operator>>): Likewise.
> * include/std/charconv (__to_chars_8, __to_chars_i)
> (__from_chars_alnum_to_val, from_chars): Likewise.
> * include/tr2/dynamic_bitset (__dynamic_bitset_base): Likewise.
> * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
> line number.
> ---
>
> Tested x86_64-linux.
>
LGTM
>
> libstdc++-v3/include/bits/char_traits.h | 5 +++-
> libstdc++-v3/include/bits/locale_conv.h | 7 +++--
> libstdc++-v3/include/bits/ostream.h | 4 +--
> libstdc++-v3/include/bits/random.tcc | 10 +++++--
> libstdc++-v3/include/bits/shared_ptr_base.h | 5 +++-
> libstdc++-v3/include/bits/stl_tree.h | 5 +++-
> libstdc++-v3/include/bits/uniform_int_dist.h | 7 +++--
> libstdc++-v3/include/bits/valarray_array.h | 15 +++++++----
> libstdc++-v3/include/experimental/numeric | 5 +++-
> libstdc++-v3/include/std/bit | 27 ++++++++++---------
> libstdc++-v3/include/std/bitset | 12 ++++++---
> libstdc++-v3/include/std/charconv | 15 ++++++-----
> libstdc++-v3/include/tr2/dynamic_bitset | 10 +++++--
> .../26_numerics/random/pr60037-neg.cc | 2 +-
> 14 files changed, 87 insertions(+), 42 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/char_traits.h
> b/libstdc++-v3/include/bits/char_traits.h
> index 67e18e89784..5ca34669302 100644
> --- a/libstdc++-v3/include/bits/char_traits.h
> +++ b/libstdc++-v3/include/bits/char_traits.h
> @@ -284,7 +284,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> }
> #endif
>
> - if _GLIBCXX17_CONSTEXPR (sizeof(_CharT) == 1 &&
> __is_trivial(_CharT))
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if _GLIBCXX_CONSTEXPR (sizeof(_CharT) == 1 && __is_trivial(_CharT))
> {
> if (__n)
> {
> @@ -298,6 +300,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> for (std::size_t __i = 0; __i < __n; ++__i)
> __s[__i] = __a;
> }
> +#pragma GCC diagnostic pop
> return __s;
> }
>
> diff --git a/libstdc++-v3/include/bits/locale_conv.h
> b/libstdc++-v3/include/bits/locale_conv.h
> index 076e14ff762..b08795dcaf5 100644
> --- a/libstdc++-v3/include/bits/locale_conv.h
> +++ b/libstdc++-v3/include/bits/locale_conv.h
> @@ -85,16 +85,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> return false;
> }
>
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> // The codecvt facet will only return noconv when the types are
> // the same, so avoid instantiating basic_string::assign otherwise
> - if _GLIBCXX17_CONSTEXPR (is_same<typename _Codecvt::intern_type,
> - typename _Codecvt::extern_type>())
> + if constexpr (is_same<typename _Codecvt::intern_type,
> + typename _Codecvt::extern_type>::value)
> if (__result == codecvt_base::noconv)
> {
> __outstr.assign(__first, __last);
> __count = __last - __first;
> return true;
> }
> +#pragma GCC diagnostic pop
>
> __outstr.resize(__outchars);
> __count = __next - __first;
> diff --git a/libstdc++-v3/include/bits/ostream.h
> b/libstdc++-v3/include/bits/ostream.h
> index d19a76ab247..caa47bead4b 100644
> --- a/libstdc++-v3/include/bits/ostream.h
> +++ b/libstdc++-v3/include/bits/ostream.h
> @@ -499,9 +499,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> #endif
> __sign = __builtin_signbit(__f) ? _To(-1.0) : _To(+1.0);
>
> - if _GLIBCXX17_CONSTEXPR (__is_same(_To, double))
> + if _GLIBCXX_CONSTEXPR (__is_same(_To, double))
> __d = __builtin_copysign(__d, __sign);
> - else if _GLIBCXX17_CONSTEXPR (__is_same(_To, long double))
> + else if _GLIBCXX_CONSTEXPR (__is_same(_To, long double))
> __d = __builtin_copysignl(__d, __sign);
> #endif
> return __d;
> diff --git a/libstdc++-v3/include/bits/random.tcc
> b/libstdc++-v3/include/bits/random.tcc
> index 752d707a5e4..53ccacb2e38 100644
> --- a/libstdc++-v3/include/bits/random.tcc
> +++ b/libstdc++-v3/include/bits/random.tcc
> @@ -849,11 +849,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> constexpr result_type __range = max() - min();
> size_t __j = __k;
> const result_type __y = _M_y - min();
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> // Avoid using slower long double arithmetic if possible.
> - if _GLIBCXX17_CONSTEXPR
> (__detail::__p1_representable_as_double(__range))
> + if constexpr (__detail::__p1_representable_as_double(__range))
> __j *= __y / (__range + 1.0);
> else
> __j *= __y / (__range + 1.0L);
> +#pragma GCC diagnostic pop
> _M_y = _M_v[__j];
> _M_v[__j] = _M_b();
>
> @@ -3244,8 +3247,11 @@ namespace __detail
> template<typename _InputIterator>
> seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
> {
> - if _GLIBCXX17_CONSTEXPR
> (__is_random_access_iter<_InputIterator>::value)
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if constexpr (__is_random_access_iter<_InputIterator>::value)
> _M_v.reserve(std::distance(__begin, __end));
> +#pragma GCC diagnostic pop
>
> for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
> _M_v.push_back(__detail::__mod<result_type,
> diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h
> b/libstdc++-v3/include/bits/shared_ptr_base.h
> index 3622e029117..b4be1b49e4d 100644
> --- a/libstdc++-v3/include/bits/shared_ptr_base.h
> +++ b/libstdc++-v3/include/bits/shared_ptr_base.h
> @@ -315,6 +315,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> inline void
> _Sp_counted_base<_S_atomic>::_M_release() noexcept
> {
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
> #if ! _GLIBCXX_TSAN
> constexpr bool __lock_free
> @@ -325,7 +327,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> // The ref-count members follow the vptr, so are aligned to
> // alignof(void*).
> constexpr bool __aligned = __alignof(long long) <= alignof(void*);
> - if _GLIBCXX17_CONSTEXPR (__lock_free && __double_word && __aligned)
> + if constexpr (__lock_free && __double_word && __aligned)
> {
> constexpr int __wordbits = __CHAR_BIT__ * sizeof(_Atomic_word);
> constexpr int __shiftbits = __double_word ? __wordbits : 0;
> @@ -359,6 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> {
> _M_release_last_use();
> }
> +#pragma GCC diagnostic pop
> }
>
> template<>
> diff --git a/libstdc++-v3/include/bits/stl_tree.h
> b/libstdc++-v3/include/bits/stl_tree.h
> index 6caf937cca9..6c12c41bba7 100644
> --- a/libstdc++-v3/include/bits/stl_tree.h
> +++ b/libstdc++-v3/include/bits/stl_tree.h
> @@ -2340,8 +2340,11 @@ namespace __rb_tree
> constexpr bool __move =
> !__move_if_noexcept_cond<value_type>::value;
> _Alloc_node __an(*this);
> _M_root() = _M_copy<__move>(__x, __an);
> - if _GLIBCXX17_CONSTEXPR (__move)
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if constexpr (__move)
> __x.clear();
> +#pragma GCC diagnostic pop
> }
> }
>
> diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h
> b/libstdc++-v3/include/bits/uniform_int_dist.h
> index d96dcbd89c0..77b1e96bd8f 100644
> --- a/libstdc++-v3/include/bits/uniform_int_dist.h
> +++ b/libstdc++-v3/include/bits/uniform_int_dist.h
> @@ -308,9 +308,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
> const __uctype __uerange = __urange + 1; // __urange can be
> zero
>
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> #if defined __UINT64_TYPE__ && defined __UINT32_TYPE__
> #if __SIZEOF_INT128__
> - if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT64_MAX__)
> + if constexpr (__urngrange == __UINT64_MAX__)
> {
> // __urng produces values that use exactly 64-bits,
> // so use 128-bit integers to downscale to desired range.
> @@ -320,7 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> }
> else
> #endif
> - if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT32_MAX__)
> + if constexpr (__urngrange == __UINT32_MAX__)
> {
> // __urng produces values that use exactly 32-bits,
> // so use 64-bit integers to downscale to desired range.
> @@ -338,6 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> while (__ret >= __past);
> __ret /= __scaling;
> }
> +#pragma GCC diagnostic pop
> }
> else if (__urngrange < __urange)
> {
> diff --git a/libstdc++-v3/include/bits/valarray_array.h
> b/libstdc++-v3/include/bits/valarray_array.h
> index 03b6f1e0a68..b5c02b77b10 100644
> --- a/libstdc++-v3/include/bits/valarray_array.h
> +++ b/libstdc++-v3/include/bits/valarray_array.h
> @@ -64,13 +64,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> __valarray_release_memory(void* __p)
> { operator delete(__p); }
>
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> +
> // Turn raw-memory into an array of _Tp filled with _Tp().
> // This is used in `valarray<T> v(n);` and in `valarray<T>::shift(n)`.
> template<typename _Tp>
> inline void
> __valarray_default_construct(_Tp* __b, _Tp* __e)
> {
> - if _GLIBCXX17_CONSTEXPR (__is_trivial(_Tp))
> + if _GLIBCXX_CONSTEXPR (__is_trivial(_Tp))
> __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp));
> else
> while (__b != __e)
> @@ -94,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> __valarray_copy_construct(const _Tp* __b, const _Tp* __e,
> _Tp* __restrict__ __o)
> {
> - if _GLIBCXX17_CONSTEXPR (__is_trivial(_Tp))
> + if _GLIBCXX_CONSTEXPR (__is_trivial(_Tp))
> {
> if (__b)
> __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp));
> @@ -110,7 +113,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n,
> size_t __s, _Tp* __restrict__ __o)
> {
> - if _GLIBCXX17_CONSTEXPR (__is_trivial(_Tp))
> + if _GLIBCXX_CONSTEXPR (__is_trivial(_Tp))
> while (__n--)
> {
> *__o++ = *__a;
> @@ -131,7 +134,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> const size_t* __restrict__ __i,
> _Tp* __restrict__ __o, size_t __n)
> {
> - if (__is_trivial(_Tp))
> + if _GLIBCXX_CONSTEXPR (__is_trivial(_Tp))
> while (__n--)
> *__o++ = __a[*__i++];
> else
> @@ -144,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> inline void
> __valarray_destroy_elements(_Tp* __b, _Tp* __e)
> {
> - if (!__is_trivial(_Tp))
> + if _GLIBCXX_CONSTEXPR (!__is_trivial(_Tp))
> while (__b != __e)
> {
> __b->~_Tp();
> @@ -152,6 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> }
> }
>
> +#pragma GCC diagnostic pop
> +
> // Fill a plain array __a[<__n>] with __t
> template<typename _Tp>
> inline void
> diff --git a/libstdc++-v3/include/experimental/numeric
> b/libstdc++-v3/include/experimental/numeric
> index 381ecf3367c..33e9731f2ce 100644
> --- a/libstdc++-v3/include/experimental/numeric
> +++ b/libstdc++-v3/include/experimental/numeric
> @@ -88,9 +88,12 @@ inline namespace fundamentals_v2
> return 0;
> _Ct __r = __m2 / __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
>
> - if _GLIBCXX17_CONSTEXPR (is_signed_v<_Ct>)
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if constexpr (is_signed_v<_Ct>)
> if (__is_constant_evaluated())
> return __r * __n2; // constant evaluation can detect overflow
> here.
> +#pragma GCC diagnostic pop
>
> bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
> __glibcxx_assert(!__overflow);
> diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
> index a4817818d19..5187c96182f 100644
> --- a/libstdc++-v3/include/std/bit
> +++ b/libstdc++-v3/include/std/bit
> @@ -153,13 +153,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> #endif // __cpp_lib_byteswap
>
> /// @cond undocumented
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
>
> template<typename _Tp>
> constexpr _Tp
> __rotl(_Tp __x, int __s) noexcept
> {
> constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits;
> - if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0)
> + if constexpr ((_Nd & (_Nd - 1)) == 0)
> {
> // Variant for power of two _Nd which the compiler can
> // easily pattern match.
> @@ -181,7 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> __rotr(_Tp __x, int __s) noexcept
> {
> constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits;
> - if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0)
> + if constexpr ((_Nd & (_Nd - 1)) == 0)
> {
> // Variant for power of two _Nd which the compiler can
> // easily pattern match.
> @@ -215,17 +217,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> constexpr auto _Nd_ul = __int_traits<unsigned long>::__digits;
> constexpr auto _Nd_u = __int_traits<unsigned>::__digits;
>
> - if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u)
> + if constexpr (_Nd <= _Nd_u)
> {
> constexpr int __diff = _Nd_u - _Nd;
> return __builtin_clz(__x) - __diff;
> }
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul)
> + else if constexpr (_Nd <= _Nd_ul)
> {
> constexpr int __diff = _Nd_ul - _Nd;
> return __builtin_clzl(__x) - __diff;
> }
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull)
> + else if constexpr (_Nd <= _Nd_ull)
> {
> constexpr int __diff = _Nd_ull - _Nd;
> return __builtin_clzll(__x) - __diff;
> @@ -272,11 +274,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> constexpr auto _Nd_ul = __int_traits<unsigned long>::__digits;
> constexpr auto _Nd_u = __int_traits<unsigned>::__digits;
>
> - if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u)
> + if constexpr (_Nd <= _Nd_u)
> return __builtin_ctz(__x);
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul)
> + else if constexpr (_Nd <= _Nd_ul)
> return __builtin_ctzl(__x);
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull)
> + else if constexpr (_Nd <= _Nd_ull)
> return __builtin_ctzll(__x);
> else // (_Nd > _Nd_ull)
> {
> @@ -314,11 +316,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> constexpr auto _Nd_ul = __int_traits<unsigned long>::__digits;
> constexpr auto _Nd_u = __int_traits<unsigned>::__digits;
>
> - if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u)
> + if constexpr (_Nd <= _Nd_u)
> return __builtin_popcount(__x);
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul)
> + else if constexpr (_Nd <= _Nd_ul)
> return __builtin_popcountl(__x);
> - else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull)
> + else if constexpr (_Nd <= _Nd_ull)
> return __builtin_popcountll(__x);
> else // (_Nd > _Nd_ull)
> {
> @@ -357,7 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> }
>
> using __promoted_type = decltype(__x << 1);
> - if _GLIBCXX17_CONSTEXPR (!is_same<__promoted_type, _Tp>::value)
> + if constexpr (!is_same<__promoted_type, _Tp>::value)
> {
> // If __x undergoes integral promotion then shifting by _Nd is
> // not undefined. In order to make the shift undefined, so that
> @@ -388,6 +390,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> return _Nd - std::__countl_zero(__x);
> }
>
> +#pragma GCC diagnostic pop
> /// @endcond
>
> #ifdef __cpp_lib_bitops // C++ >= 20
> diff --git a/libstdc++-v3/include/std/bitset
> b/libstdc++-v3/include/std/bitset
> index c07117ae8d8..8b5d270c2a9 100644
> --- a/libstdc++-v3/include/std/bitset
> +++ b/libstdc++-v3/include/std/bitset
> @@ -1605,6 +1605,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
> typedef std::basic_istream<_CharT, _Traits> __istream_type;
> typedef typename __istream_type::ios_base __ios_base;
>
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> struct _Buffer
> {
> static _GLIBCXX_CONSTEXPR bool _S_use_alloca() { return _Nb <=
> 256; }
> @@ -1613,18 +1615,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
>
> ~_Buffer()
> {
> - if _GLIBCXX17_CONSTEXPR (!_S_use_alloca())
> + if _GLIBCXX_CONSTEXPR (!_S_use_alloca())
> delete[] _M_ptr;
> }
>
> _CharT* const _M_ptr;
> };
> _CharT* __ptr;
> - if _GLIBCXX17_CONSTEXPR (_Buffer::_S_use_alloca())
> + if _GLIBCXX_CONSTEXPR (_Buffer::_S_use_alloca())
> __ptr = (_CharT*)__builtin_alloca(_Nb);
> else
> __ptr = new _CharT[_Nb];
> const _Buffer __buf(__ptr);
> +#pragma GCC diagnostic pop
>
> // _GLIBCXX_RESOLVE_LIB_DEFECTS
> // 303. Bitset input operator underspecified
> @@ -1673,7 +1676,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
> { __is._M_setstate(__ios_base::badbit); }
> }
>
> - if _GLIBCXX17_CONSTEXPR (_Nb)
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if _GLIBCXX_CONSTEXPR (_Nb)
> {
> if (size_t __len = __ptr - __buf._M_ptr)
> __x.template _M_copy_from_ptr<_CharT, _Traits>(__buf._M_ptr,
> __len,
> @@ -1682,6 +1687,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
> else
> __state |= __ios_base::failbit;
> }
> +#pragma GCC diagnostic pop
> if (__state)
> __is.setstate(__state);
> return __is;
> diff --git a/libstdc++-v3/include/std/charconv
> b/libstdc++-v3/include/std/charconv
> index 75fcb7157c5..dda49ce72d0 100644
> --- a/libstdc++-v3/include/std/charconv
> +++ b/libstdc++-v3/include/std/charconv
> @@ -35,6 +35,7 @@
>
> #pragma GCC diagnostic push
> #pragma GCC diagnostic ignored "-Wpedantic" // __int128
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
>
> #include <bits/requires_hosted.h> // for error codes
>
> @@ -239,7 +240,7 @@ namespace __detail
> to_chars_result __res;
> unsigned __len = 0;
>
> - if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Tp>::__digits <=
> 16)
> + if constexpr (__gnu_cxx::__int_traits<_Tp>::__digits <= 16)
> {
> __len = __val > 077777u ? 6u
> : __val > 07777u ? 5u
> @@ -336,7 +337,7 @@ namespace __detail
> *__first = '0';
> return { __first + 1, errc{} };
> }
> - else if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value)
> + else if constexpr (std::is_signed<_Tp>::value)
> if (__value < 0)
> {
> *__first++ = '-';
> @@ -452,7 +453,7 @@ namespace __detail
> _GLIBCXX20_CONSTEXPR unsigned char
> __from_chars_alnum_to_val(unsigned char __c)
> {
> - if _GLIBCXX17_CONSTEXPR (_DecOnly)
> + if constexpr (_DecOnly)
> return static_cast<unsigned char>(__c - '0');
> else
> return
> __from_chars_alnum_to_val_table<_DecOnly>::value.__data[__c];
> @@ -562,7 +563,7 @@ namespace __detail
> from_chars_result __res{__first, {}};
>
> int __sign = 1;
> - if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value)
> + if constexpr (std::is_signed<_Tp>::value)
> if (__first != __last && *__first == '-')
> {
> __sign = -1;
> @@ -595,7 +596,7 @@ namespace __detail
> __res.ec = errc::result_out_of_range;
> else
> {
> - if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value)
> + if constexpr (std::is_signed<_Tp>::value)
> {
> _Tp __tmp;
> if (__builtin_mul_overflow(__val, __sign, &__tmp))
> @@ -605,8 +606,8 @@ namespace __detail
> }
> else
> {
> - if _GLIBCXX17_CONSTEXPR
> (__gnu_cxx::__int_traits<_Up>::__max
> - > __gnu_cxx::__int_traits<_Tp>::__max)
> + if constexpr (__gnu_cxx::__int_traits<_Up>::__max
> + > __gnu_cxx::__int_traits<_Tp>::__max)
> {
> if (__val > __gnu_cxx::__int_traits<_Tp>::__max)
> __res.ec = errc::result_out_of_range;
> diff --git a/libstdc++-v3/include/tr2/dynamic_bitset
> b/libstdc++-v3/include/tr2/dynamic_bitset
> index 2446f355d55..b308e7283c2 100644
> --- a/libstdc++-v3/include/tr2/dynamic_bitset
> +++ b/libstdc++-v3/include/tr2/dynamic_bitset
> @@ -99,7 +99,9 @@ namespace tr2
> if (__val == 0)
> return;
>
> - if _GLIBCXX17_CONSTEXPR (sizeof(__val) == sizeof(block_type))
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> + if constexpr (sizeof(__val) == sizeof(block_type))
> _M_w[0] = __val;
> else
> {
> @@ -111,6 +113,7 @@ namespace tr2
> __val >>= _S_bits_per_block;
> }
> }
> +#pragma GCC diagnostic pop
> }
>
> void
> @@ -667,13 +670,16 @@ namespace tr2
> operator=(dynamic_bitset&& __b)
> noexcept(std::is_nothrow_move_assignable<_Base>::value)
> {
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
> static_cast<_Base&>(*this) = static_cast<_Base&&>(__b);
> _M_Nb = __b._M_Nb;
> - if _GLIBCXX17_CONSTEXPR
> (std::is_nothrow_move_assignable<_Base>::value)
> + if constexpr (std::is_nothrow_move_assignable<_Base>::value)
> __b._M_Nb = 0;
> else if (get_allocator() == __b.get_allocator())
> __b._M_Nb = 0;
> return *this;
> +#pragma GCC diagnostic pop
> }
>
> /**
> diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
> b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
> index 3c5aa7feefc..0afba654152 100644
> --- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
> +++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
> @@ -12,4 +12,4 @@ auto x = std::generate_canonical<std::size_t,
>
> // { dg-error "static assertion failed: template argument must be a
> floating point type" "" { target *-*-* } 270 }
>
> -// { dg-error "static assertion failed: template argument must be a
> floating point type" "" { target *-*-* } 3351 }
> +// { dg-error "static assertion failed: template argument must be a
> floating point type" "" { target *-*-* } 3357 }
> --
> 2.49.0
>
>