[Bug libstdc++/88113] Woverflow warning in memory_resource.cc (struct bitset), for 16-bit size_t

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 21 18:41:00 GMT 2018


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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Wed Nov 21 18:40:37 2018
New Revision: 266352

URL: https://gcc.gnu.org/viewcvs?rev=266352&root=gcc&view=rev
Log:
PR libstdc++/88113 use size_type consistently instead of size_t

On 16-bit msp430-elf size_t is either 16 bits or 20 bits, and so can't
represent all values of the uint32_t type used for bitset::size_type.
Using the smaller of size_t and uint32_t for size_type ensures it fits
in size_t.

        PR libstdc++/88113
        * src/c++17/memory_resource.cc (bitset::size_type): Use the smaller
        of uint32_t and size_t.
        (bitset::size(), bitset::free(), bitset::update_next_word())
        (bitset::max_blocks_per_chunk(), bitset::max_word_index()): Use
        size_type consistently instead of size_t.
        (chunk): Adjust static_assert checking sizeof(chunk).

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/src/c++17/memory_resource.cc


More information about the Gcc-bugs mailing list