]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix src/c++17/memory_resource for H8 targets [PR107801]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 28 Nov 2022 13:28:53 +0000 (13:28 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 28 Nov 2022 16:57:36 +0000 (16:57 +0000)
commit75e562d2c4303d3918be9d1563284b0c580c5e45
tree24dff8d635cd42d1448fa1d825d631ab8b39fde9
parenta7b97a1f6b9d4993545525fd5cb334ae640ddf45
libstdc++: Fix src/c++17/memory_resource for H8 targets [PR107801]

This fixes compilation failures for H8 multilibs. For the normal
multilib (ILP16L32?), the chunk struct does not have the expected size,
because uint32_t is type long and has alignment 4 (by default). This
forces sizeof(chunk) to be 12 instead of the expected 10. We can fix
that by using bitset::size_type instead of uint32_t, so that we only use
a 16-bit size when size_t and pointers are 16-bit types.

For the I32LP16 multilibs that use -mint32 int is wider than size_t
and so arithmetic expressions involving size_t promote to int. This
means we need some explicit casts back to size_t.

libstdc++-v3/ChangeLog:

PR libstdc++/107801
* src/c++17/memory_resource.cc (chunk::_M_bytes): Change type
from uint32_t to bitset::size_type. Adjust static assertion.
(__pool_resource::_Pool::replenish): Cast to size_t after
multiplication instead of before.
(__pool_resource::_M_alloc_pools): Ensure both arguments to
std::max have type size_t.
libstdc++-v3/src/c++17/memory_resource.cc