Skip to content

Commit f3c2a3d

Browse files
authored
[libc++] Mark static variables of locale::id as constinit (#65783)
The dylib contains multiple global variables of type locale::id. Those can be marked as constinit to make it clear that static initialization is performed.
1 parent 595cd45 commit f3c2a3d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

libcxx/src/locale.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ locale::facet::__on_zero_shared() noexcept
688688

689689
// locale::id
690690

691-
int32_t locale::id::__next_id = 0;
691+
constinit int32_t locale::id::__next_id = 0;
692692

693693
namespace
694694
{
@@ -836,7 +836,7 @@ const ctype_base::mask ctype_base::graph;
836836
// template <> class ctype<wchar_t>;
837837

838838
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
839-
locale::id ctype<wchar_t>::id;
839+
constinit locale::id ctype<wchar_t>::id;
840840

841841
ctype<wchar_t>::~ctype()
842842
{
@@ -969,7 +969,7 @@ ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfau
969969

970970
// template <> class ctype<char>;
971971

972-
locale::id ctype<char>::id;
972+
constinit locale::id ctype<char>::id;
973973

974974
const size_t ctype<char>::table_size;
975975

@@ -1524,7 +1524,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
15241524

15251525
// template <> class codecvt<char, char, mbstate_t>
15261526

1527-
locale::id codecvt<char, char, mbstate_t>::id;
1527+
constinit locale::id codecvt<char, char, mbstate_t>::id;
15281528

15291529
codecvt<char, char, mbstate_t>::~codecvt()
15301530
{
@@ -1586,7 +1586,7 @@ codecvt<char, char, mbstate_t>::do_max_length() const noexcept
15861586
// template <> class codecvt<wchar_t, char, mbstate_t>
15871587

15881588
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1589-
locale::id codecvt<wchar_t, char, mbstate_t>::id;
1589+
constinit locale::id codecvt<wchar_t, char, mbstate_t>::id;
15901590

15911591
codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
15921592
: locale::facet(refs),
@@ -3192,7 +3192,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
31923192

31933193
// template <> class codecvt<char16_t, char, mbstate_t>
31943194

3195-
locale::id codecvt<char16_t, char, mbstate_t>::id;
3195+
constinit locale::id codecvt<char16_t, char, mbstate_t>::id;
31963196

31973197
codecvt<char16_t, char, mbstate_t>::~codecvt()
31983198
{
@@ -3271,7 +3271,7 @@ codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept
32713271

32723272
// template <> class codecvt<char16_t, char8_t, mbstate_t>
32733273

3274-
locale::id codecvt<char16_t, char8_t, mbstate_t>::id;
3274+
constinit locale::id codecvt<char16_t, char8_t, mbstate_t>::id;
32753275

32763276
codecvt<char16_t, char8_t, mbstate_t>::~codecvt()
32773277
{
@@ -3350,7 +3350,7 @@ codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept
33503350

33513351
// template <> class codecvt<char32_t, char, mbstate_t>
33523352

3353-
locale::id codecvt<char32_t, char, mbstate_t>::id;
3353+
constinit locale::id codecvt<char32_t, char, mbstate_t>::id;
33543354

33553355
codecvt<char32_t, char, mbstate_t>::~codecvt()
33563356
{
@@ -3429,7 +3429,7 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept
34293429

34303430
// template <> class codecvt<char32_t, char8_t, mbstate_t>
34313431

3432-
locale::id codecvt<char32_t, char8_t, mbstate_t>::id;
3432+
constinit locale::id codecvt<char32_t, char8_t, mbstate_t>::id;
34333433

34343434
codecvt<char32_t, char8_t, mbstate_t>::~codecvt()
34353435
{
@@ -4628,9 +4628,9 @@ static bool checked_string_to_char_convert(char& dest,
46284628

46294629
// numpunct<char> && numpunct<wchar_t>
46304630

4631-
locale::id numpunct< char >::id;
4631+
constinit locale::id numpunct<char>::id;
46324632
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4633-
locale::id numpunct<wchar_t>::id;
4633+
constinit locale::id numpunct<wchar_t>::id;
46344634
#endif
46354635

46364636
numpunct<char>::numpunct(size_t refs)

0 commit comments

Comments
 (0)