Skip to content

Commit 21aa57e

Browse files
committed
libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]
libstdc++-v3/ChangeLog: PR libstdc++/114519 * include/bits/unicode.h (_Utf8_view): Guard with check for char8_t being enabled. (__literal_encoding_is_unicode): Guard use of char8_t with check for it being enabled. * testsuite/std/format/functions/114519.cc: New test.
1 parent ca2f7c8 commit 21aa57e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

libstdc++-v3/include/bits/unicode.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,10 @@ namespace __unicode
578578
constexpr bool empty() const { return ranges::empty(_M_base); }
579579
};
580580

581+
#ifdef __cpp_char8_t
581582
template<typename _View>
582583
using _Utf8_view = _Utf_view<char8_t, _View>;
584+
#endif
583585
template<typename _View>
584586
using _Utf16_view = _Utf_view<char16_t, _View>;
585587
template<typename _View>
@@ -991,12 +993,14 @@ inline namespace __v15_1_0
991993
consteval bool
992994
__literal_encoding_is_unicode()
993995
{
994-
if constexpr (is_same_v<_CharT, char8_t>)
995-
return true;
996-
else if constexpr (is_same_v<_CharT, char16_t>)
996+
if constexpr (is_same_v<_CharT, char16_t>)
997997
return true;
998998
else if constexpr (is_same_v<_CharT, char32_t>)
999999
return true;
1000+
#ifdef __cpp_char8_t
1001+
else if constexpr (is_same_v<_CharT, char8_t>)
1002+
return true;
1003+
#endif
10001004

10011005
const char* __enc = "";
10021006

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// { dg-do compile { target c++20 } }
2+
// { dg-options "-fno-char8_t" }
3+
#include <format>

0 commit comments

Comments
 (0)