https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118681
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- This is a better fix, rounding up to the next multiple of the alignment: const auto block_size = ((bytes + alignment - 1) / alignment) * alignment; The codegen isn't great for this though, as the compiler doesn't know that alignment is a power of two (even if we force it to be with bit_ceil(alignment)) and so it always does a division rather than a shift.