]> 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:29:50 +0000 (17:29 +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 65d63e433e08592f84f64347344055b692aac326..50e4708271429e63036390cff9aa405089b333ba 100644 (file)
@@ -1020,7 +1020,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 65f923993fa320ba773ff31a29a4801828d91785..dc93c4c07bbc0dc8fcfbfda5dd6044372f6964e6 100644 (file)
@@ -235,7 +235,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)
        {