public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104875] New: libstdc++-v3/src/c++11/codecvt.cc:312:24: warning: left shift count >= width of type
@ 2022-03-10 23:51 redi at gcc dot gnu.org
  2022-03-11  0:22 ` [Bug libstdc++/104875] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-10 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-16 15:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 23:51 [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
2022-03-11  0:22 ` [Bug libstdc++/104875] " redi at gcc dot gnu.org
2022-03-14 13:09 ` cvs-commit at gcc dot gnu.org
2022-11-23 17:58 ` gjl at gcc dot gnu.org
2022-11-23 18:06 ` redi at gcc dot gnu.org
2023-05-16 12:50 ` cvs-commit at gcc dot gnu.org
2023-05-16 15:03 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).