Skip to content

Commit a0168f1

Browse files
authored
<xlocale>: Use static_cast to eliminate implicit conversions between different charN_t types (#5653)
1 parent c2097a1 commit a0168f1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

stl/inc/xlocale

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ protected:
15051505
}
15061506

15071507
const char8_t* _Peek = _First1;
1508-
char32_t _Code_point = _Lead_byte;
1508+
char32_t _Code_point = static_cast<char32_t>(_Lead_byte);
15091509
do {
15101510
const char8_t _By = *++_Peek;
15111511
if ((_By & 0b1100'0000u) != 0b1000'0000u) { // out-of-sequence lead byte
@@ -1551,7 +1551,7 @@ protected:
15511551
return partial;
15521552
}
15531553

1554-
char32_t _Code_point = *_First1;
1554+
char32_t _Code_point = static_cast<char32_t>(*_First1);
15551555
if (_Code_point < 0x80u) { // encode 1-byte sequence
15561556
*_First2 = static_cast<char8_t>(_Code_point);
15571557
continue;
@@ -1613,7 +1613,7 @@ protected:
16131613
const auto _Old_first1 = _First1;
16141614

16151615
for (; _First1 != _Last1 && _Count > 0u; ++_First1, --_Count) {
1616-
char32_t _Code_point = *_First1;
1616+
char32_t _Code_point = static_cast<char32_t>(*_First1);
16171617
if (_Code_point < 0b1000'0000u) { // single-byte sequence
16181618
continue;
16191619
}
@@ -1755,7 +1755,7 @@ protected:
17551755

17561756
char8_t _Lead_byte = *_First1;
17571757
if (_Lead_byte < 0b1000'0000u) { // single-byte sequence
1758-
*_First2 = _Lead_byte;
1758+
*_First2 = static_cast<char32_t>(_Lead_byte);
17591759
continue;
17601760
}
17611761

@@ -1782,7 +1782,7 @@ protected:
17821782
}
17831783

17841784
const char8_t* _Peek = _First1;
1785-
char32_t _Code_point = _Lead_byte;
1785+
char32_t _Code_point = static_cast<char32_t>(_Lead_byte);
17861786
do {
17871787
const char8_t _By = *++_Peek;
17881788
if ((_By & 0b1100'0000u) != 0b1000'0000u) { // out-of-sequence lead byte
@@ -1868,7 +1868,7 @@ protected:
18681868
const auto _Old_first1 = _First1;
18691869

18701870
for (; _First1 != _Last1 && _Count > 0u; ++_First1, --_Count) {
1871-
char32_t _Code_point = *_First1;
1871+
char32_t _Code_point = static_cast<char32_t>(*_First1);
18721872
if (_Code_point < 0b1000'0000u) { // single-byte sequence
18731873
continue;
18741874
}

0 commit comments

Comments
 (0)