https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118681
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:ac2fb60a67d6d1de6446c25c5623b8a1389f4770 commit r16-2112-gac2fb60a67d6d1de6446c25c5623b8a1389f4770 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri Jul 4 16:44:13 2025 +0100 libstdc++: Ensure pool resources meet alignment requirements [PR118681] 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 <tkami...@redhat.com>