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.