[Bug libstdc++/104875] New: libstdc++-v3/src/c++11/codecvt.cc:312:24: warning: left shift count >= width of type
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 10 23:51:37 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104875
Bug ID: 104875
Summary: libstdc++-v3/src/c++11/codecvt.cc:312:24: warning:
left shift count >= width of type
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Target: avr, msp430-elf
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++11/codecvt.cc:312:24: warning:
left shift count >= width of type [-Wshift-count-overflow]
312 | char32_t c = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4 -
0x3C82080;
| ~~~~^~~~~~
c1 is an unsigned char, so c1 << 18 promotes to int, but for 16-bit int that
doesn't work as intended.
It needs to be converted to a 32-bit type first, e.g. (char32_t)c1 << 18
More information about the Gcc-bugs
mailing list