[Bug libstdc++/97132] assume_aligned is not constexpr

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Sep 21 13:29:07 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97132

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f10ed928e2f8ecc2c859abff8f2f9296b11b8d95

commit r11-3324-gf10ed928e2f8ecc2c859abff8f2f9296b11b8d95
Author: Jonathan Wakely <jwakely@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.

    This change also removes the preprocessor branch that works around
    uintptr_t not being available. We already assume that type is present
    elsewhere in the library.

    libstdc++-v3/ChangeLog:

            PR libstdc++/97132
            * include/bits/align.h (align) [!_GLIBCXX_USE_C99_STDINT_TR1]:
            Remove unused code.
            (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.


More information about the Gcc-bugs mailing list