]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix constexpr functions to conform to older standards
authorJonathan Wakely <jwakely@redhat.com>
Wed, 9 Aug 2023 10:11:31 +0000 (11:11 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 27 Sep 2023 16:25:21 +0000 (17:25 +0100)
Some constexpr functions were inadvertently relying on relaxed constexpr
rules from later standards.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path::string): Use
_GLIBCXX17_CONSTEXPR not _GLIBCXX_CONSTEXPR for 'if constexpr'.
* include/std/charconv (__to_chars_8): Initialize variable for
C++17 constexpr rules.

(cherry picked from commit b3a2b307b9deea719fb725a86df43b82176fe459)

libstdc++-v3/include/experimental/bits/fs_path.h
libstdc++-v3/include/std/charconv

index ba6acb2158d7c3c9085f364eb2cccf183326aea6..c13195a6ba9c5adf892d799addc7474da98325fb 100644 (file)
@@ -1049,7 +1049,7 @@ namespace __detail
     inline std::basic_string<_CharT, _Traits, _Allocator>
     path::string(const _Allocator& __a) const
     {
-      if _GLIBCXX_CONSTEXPR (is_same<_CharT, value_type>::value)
+      if _GLIBCXX17_CONSTEXPR (is_same<_CharT, value_type>::value)
        return { _M_pathname.begin(), _M_pathname.end(), __a };
 
       using _WString = basic_string<_CharT, _Traits, _Allocator>;
index 533320ea08521982eafc82511e75fc733a7265eb..b4d37435fa0188b40d9230f601d985e1e8eaeaa3 100644 (file)
@@ -236,7 +236,7 @@ namespace __detail
       static_assert(is_unsigned<_Tp>::value, "implementation bug");
 
       to_chars_result __res;
-      unsigned __len;
+      unsigned __len = 0;
 
       if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Tp>::__digits <= 16)
        {