public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
@ 2022-11-27  0:12 uaa at mx5 dot nisiq.net
  2022-11-27  0:28 ` [Bug libstdc++/107885] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: uaa at mx5 dot nisiq.net @ 2022-11-27  0:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

            Bug ID: 107885
           Summary: H8/300: libsupc++/hash_bytes.cc fix
                    shift-count-overflow warning
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: uaa at mx5 dot nisiq.net
  Target Milestone: ---

Created attachment 53974
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53974&action=edit
add cast to static_cast<unsigned char>(buf[x])

On building gcc-12.2.0 with newlib-4.1.0 (newlib and libgloss) and
binutils-2.36.1 on Debian-11.5/amd64.

gcc/config/h8300/t-h8300 is modified with:

    MULTILIB_OPTIONS = ms/msx mint32
    MULTILIB_DIRNAMES = h8300s h8sx int32

to disable building H8 normal mode library.

gcc configuration is:

    ../configure --target=h8300-unknown-elf --enable-languages=c,c++ \
    --prefix=/home/uaa/h8300 --with-newlib --disable-nls --disable-libssp \
    --disable-libgomp --disable-libstdcxx-pch \
    --disable-libstdcxx-filesystem-ts --with-newlib --disable-wchar_t

libstdc++-v3/libsupc++/hash_bytes.cc has warning,
due to the size of int is 16bit (H8/300 default).

/bin/bash ../libtool --tag CXX --tag disable-shared   --mode=compile
/home/uaa/gcc-12.2.0/h8300-unknown-elf/./gcc/xgcc -shared-libgcc
-B/home/uaa/gcc-12.2.0/h8300-unknown-elf/./gcc -nostdinc++
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/src
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/src/.libs
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/libsupc++/.libs
-nostdinc
-B/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/newlib/
-isystem
/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/newlib/targ-include
-isystem /home/uaa/gcc-12.2.0/newlib/libc/include
-B/home/uaa/h8300/h8300-unknown-elf/bin/
-B/home/uaa/h8300/h8300-unknown-elf/lib/ -isystem
/home/uaa/h8300/h8300-unknown-elf/include -isystem
/home/uaa/h8300/h8300-unknown-elf/sys-include  -ms
-I/home/uaa/gcc-12.2.0/libstdc++-v3/../libgcc
-I/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/include/h8300-unknown-elf
-I/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/include
-I/home/uaa/gcc-12.2.0/libstdc++-v3/libsupc++     -fno-implicit-templates 
-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 
-fdiagnostics-show-location=once    -ffunction-sections -fdata-sections 
-frandom-seed=hash_bytes.lo  -g -O2  -ms  -c -o hash_bytes.lo
../../../../../libstdc++-v3/libsupc++/hash_bytes.cc
libtool: compile:  /home/uaa/gcc-12.2.0/h8300-unknown-elf/./gcc/xgcc
-shared-libgcc -B/home/uaa/gcc-12.2.0/h8300-unknown-elf/./gcc -nostdinc++
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/src
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/src/.libs
-L/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/libsupc++/.libs
-nostdinc
-B/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/newlib/
-isystem
/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/newlib/targ-include
-isystem /home/uaa/gcc-12.2.0/newlib/libc/include
-B/home/uaa/h8300/h8300-unknown-elf/bin/
-B/home/uaa/h8300/h8300-unknown-elf/lib/ -isystem
/home/uaa/h8300/h8300-unknown-elf/include -isystem
/home/uaa/h8300/h8300-unknown-elf/sys-include -ms
-I/home/uaa/gcc-12.2.0/libstdc++-v3/../libgcc
-I/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/include/h8300-unknown-elf
-I/home/uaa/gcc-12.2.0/h8300-unknown-elf/h8300-unknown-elf/h8300s/libstdc++-v3/include
-I/home/uaa/gcc-12.2.0/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall
-Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once
-ffunction-sections -fdata-sections -frandom-seed=hash_bytes.lo -g -O2 -ms -c
../../../../../libstdc++-v3/libsupc++/hash_bytes.cc -o hash_bytes.o
../../../../../libstdc++-v3/libsupc++/hash_bytes.cc: In function 'std::size_t
std::_Hash_bytes(const void*, size_t, size_t)':
../../../../../libstdc++-v3/libsupc++/hash_bytes.cc:97:52: warning: left shift
count >= width of type [-Wshift-count-overflow]
   97 |         hash ^= static_cast<unsigned char>(buf[2]) << 16;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~

suggested remedy is attached.

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

* [Bug libstdc++/107885] H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
  2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
@ 2022-11-27  0:28 ` redi at gcc dot gnu.org
  2022-11-28 10:51 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-27  0:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-11-27

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

* [Bug libstdc++/107885] H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
  2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
  2022-11-27  0:28 ` [Bug libstdc++/107885] " redi at gcc dot gnu.org
@ 2022-11-28 10:51 ` redi at gcc dot gnu.org
  2022-11-28 16:57 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 10:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug libstdc++/107885] H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
  2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
  2022-11-27  0:28 ` [Bug libstdc++/107885] " redi at gcc dot gnu.org
  2022-11-28 10:51 ` redi at gcc dot gnu.org
@ 2022-11-28 16:57 ` cvs-commit at gcc dot gnu.org
  2022-11-28 17:02 ` redi at gcc dot gnu.org
  2023-10-28 22:31 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-28 16:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:7b79fa930917da735f02b4f6911dfbb0a91f9714

commit r13-4369-g7b79fa930917da735f02b4f6911dfbb0a91f9714
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Nov 28 10:52:23 2022 +0000

    libstdc++: Fix _Hash_bytes for I16LP32 targets [PR107885]

    For H8/300 size_t is 32 bits wide, but (unsigned char)buf[2] << 16
    promotes to int which is only 16 bits wide. The shift is then undefined.
    This fixes it by converting to size_t before shifting.

    libstdc++-v3/ChangeLog:

            PR libstdc++/107885
            * libsupc++/hash_bytes.cc (_Hash_bytes): Convert to size_t
            instead of implicit integer promotion to 16 bits.

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

* [Bug libstdc++/107885] H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
  2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
                   ` (2 preceding siblings ...)
  2022-11-28 16:57 ` cvs-commit at gcc dot gnu.org
@ 2022-11-28 17:02 ` redi at gcc dot gnu.org
  2023-10-28 22:31 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 17:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk.

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

* [Bug libstdc++/107885] H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
  2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
                   ` (3 preceding siblings ...)
  2022-11-28 17:02 ` redi at gcc dot gnu.org
@ 2023-10-28 22:31 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2023-10-28 22:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107885

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---
No plans to backport this.

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

end of thread, other threads:[~2023-10-28 22:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27  0:12 [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning uaa at mx5 dot nisiq.net
2022-11-27  0:28 ` [Bug libstdc++/107885] " redi at gcc dot gnu.org
2022-11-28 10:51 ` redi at gcc dot gnu.org
2022-11-28 16:57 ` cvs-commit at gcc dot gnu.org
2022-11-28 17:02 ` redi at gcc dot gnu.org
2023-10-28 22:31 ` law 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).