https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98641
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > assume_aligned is something different, I guess __builtin_is_aligned expands > to an actual runtime check (perhaps optimized away if the pointer can't be > misaligned). But we could do this: --- a/libstdc++-v3/include/bits/align.h +++ b/libstdc++-v3/include/bits/align.h @@ -98,7 +98,7 @@ align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept { // This function is expected to be used in hot code, where // __glibcxx_assert would add unwanted overhead. - _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0); + _GLIBCXX_DEBUG_ASSERT(__builtin_is_aligned(__ptr, _Align)); return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); } }