diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2025-07-04 16:44:13 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2025-07-08 21:48:15 +0100 |
commit | ac2fb60a67d6d1de6446c25c5623b8a1389f4770 (patch) | |
tree | 583f93dad706985db631191df4b72b8b343f94e4 /gcc/analyzer | |
parent | 7d11ae1dd95a0296eeb5c14bfe3a5d4ec8873e3b (diff) | |
download | gcc-master.zip gcc-master.tar.gz gcc-master.tar.bz2 |
For allocations with size > alignment and size % alignment != 0 we were
sometimes returning pointers that did not meet the requested aligment.
For example, allocate(24, 16) would select the pool for 24-byte objects
and the second allocation from that pool (at offset 24 bytes into the
pool) is only 8-byte aligned not 16-byte aligned.
The pool resources need to round up the requested allocation size to a
multiple of the alignment, so that the selected pool will always return
allocations that meet the alignment requirement.
libstdc++-v3/ChangeLog:
PR libstdc++/118681
* src/c++17/memory_resource.cc (choose_block_size): New
function.
(synchronized_pool_resource::do_allocate): Use choose_block_size
to determine appropriate block size.
(synchronized_pool_resource::do_deallocate): Likewise
(unsynchronized_pool_resource::do_allocate): Likewise.
(unsynchronized_pool_resource::do_deallocate): Likewise
* testsuite/20_util/synchronized_pool_resource/118681.cc: New
test.
* testsuite/20_util/unsynchronized_pool_resource/118681.cc: New
test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Diffstat (limited to 'gcc/analyzer')
0 files changed, 0 insertions, 0 deletions