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

Reply via email to