]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make std::assume_aligned a constexpr function [PR 97132]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 21 Sep 2020 13:28:58 +0000 (14:28 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 19 Oct 2020 21:25:27 +0000 (22:25 +0100)
commit90c9484b12dd8a05b5314f5cb9847df46024a194
treec22c747c30e6e0207aa7f617456911c78bf4246c
parent53325dec8e01775af3eb9231d10f2afa1b8d5559
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)
libstdc++-v3/include/std/memory
libstdc++-v3/testsuite/20_util/assume_aligned/1.cc
libstdc++-v3/testsuite/20_util/assume_aligned/97132.cc [new file with mode: 0644]