public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "uaa at mx5 dot nisiq.net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107885] New: H8/300: libsupc++/hash_bytes.cc fix shift-count-overflow warning
Date: Sun, 27 Nov 2022 00:12:24 +0000	[thread overview]
Message-ID: <bug-107885-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-11-27  0:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27  0:12 uaa at mx5 dot nisiq.net [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107885-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).