https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88113
Bug ID: 88113 Summary: Woverflow warning in memory_resource.cc (struct bitset), for 16-bit size_t Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jozef.l at mittosystems dot com Target Milestone: --- In the definition of struct bitset in libstdc++-v3/src/c++17/memory_resource.cc, "size_type" (using uint32_t), and size_t appear to be used interchangeably. However, for some targets size_t != uint32_t, for example msp430-elf uses uint16_t for size_t in the small memory model, and "unsigned __int20" in the large memory model. This results in a warning: > ../../../../../libstdc++-v3/src/c++17/memory_resource.cc: In static member > function 'static constexpr std::size_t > std::pmr::{anonymous}::bitset::max_blocks_per_chunk()': > ../../../../../libstdc++-v3/src/c++17/memory_resource.cc:401:39: warning: > conversion from 'long long unsigned int' to 'std::size_t' {aka 'unsigned > int'} changes value from '524287' to '65535' [-Woverflow] > 401 | { return (1ull << _S_size_digits) - 1; } > | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ "_S_size_digits" uses "size_type" to calculate the number of digits, whilst "max_blocks_per_chunk" returns "size_t".