https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97132
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:77923ad01415f6e72af844cbef5227f5b5a9fb4b commit r9-9003-g77923ad01415f6e72af844cbef5227f5b5a9fb4b Author: Jonathan Wakely <jwak...@redhat.com> Date: Mon Sep 21 14:28:58 2020 +0100 libstdc++: Make std::assume_aligned a constexpr function [PR 97132] The cast from void* to T* in std::assume_aligned is not valid in a constexpr function. The optimization hint is redundant during constant evaluation anyway (the compiler can see the object and knows its alignment). Simply return the original pointer without applying the __builtin_assume_aligned hint to it when doing constant evaluation. libstdc++-v3/ChangeLog: PR libstdc++/97132 * include/std/memory (assume_aligned): Do not use __builtin_assume_aligned during constant evaluation. * testsuite/20_util/assume_aligned/1.cc: Improve test. * testsuite/20_util/assume_aligned/97132.cc: New test. (cherry picked from commit f10ed928e2f8ecc2c859abff8f2f9296b11b8d95)