public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/107921] New: Overflow warnings in libsupc++/hash_bytes.cc for msp430-elf -mlarge
@ 2022-11-29 17:29 redi at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: redi at gcc dot gnu.org @ 2022-11-29 17:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107921
Bug ID: 107921
Summary: Overflow warnings in libsupc++/hash_bytes.cc for
msp430-elf -mlarge
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: build
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Target: msp430-elf
When building libstdc++ for msp430-elf the "large" multilib shows:
/home/jwakely/src/gcc/gcc/libstdc++-v3/libsupc++/hash_bytes.cc: In function
'std::size_t std::_Hash_bytes(const void*, size_t, size_t)':
/home/jwakely/src/gcc/gcc/libstdc++-v3/libsupc++/hash_bytes.cc:76:22: warning:
unsigned conversion from 'long int' to 'std::size_t' {aka '__int20 unsigned'}
changes value from '1540483477' to '125333' [-Woverflow]
76 | const size_t m = 0x5bd1e995;
| ^~~~~~~~~~
/home/jwakely/src/gcc/gcc/libstdc++-v3/libsupc++/hash_bytes.cc:85:16: warning:
right shift count >= width of type [-Wshift-count-overflow]
85 | k ^= k >> 24;
| ~~^~~~~
I think this is because size_t is an alias for __int20 which means we use this
preprocessor branch:
#if __SIZEOF_SIZE_T__ == 4
// Implementation of Murmur hash for 32-bit size_t.
size_t
_Hash_bytes(const void* ptr, size_t len, size_t seed)
{
const size_t m = 0x5bd1e995;
sizeof(__int20) is 4, but it is not a 32-bit type.
We should probably be using __SIZE_WIDTH__ == 32 instead.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-29 17:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 17:29 [Bug libstdc++/107921] New: Overflow warnings in libsupc++/hash_bytes.cc for msp430-elf -mlarge 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).