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

--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:08463348c5cce84dc3c64ac4fbb20e2795ee104f

commit r13-8908-g08463348c5cce84dc3c64ac4fbb20e2795ee104f
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Jun 18 13:27:02 2024 +0100

    libstdc++: Fix std::to_array for trivial-ish types [PR115522]

    Due to PR c++/85723 the std::is_trivial trait is true for types with a
    deleted default constructor, so the use of std::is_trivial in
    std::to_array is not sufficient to ensure the type can be trivially
    default constructed then filled using memcpy.

    I also forgot that a type with a deleted assignment operator can still
    be trivial, so we also need to check that it's assignable because the
    is_constant_evaluated() path can't use memcpy.

    Replace the uses of std::is_trivial with std::is_trivially_copyable
    (needed for memcpy), std::is_trivially_default_constructible (needed so
    that the default construction is valid and does no work) and
    std::is_copy_assignable (needed for the constant evaluation case).

    libstdc++-v3/ChangeLog:

            PR libstdc++/115522
            * include/std/array (to_array): Workaround the fact that
            std::is_trivial is not sufficient to check that a type is
            trivially default constructible and assignable.
            * testsuite/23_containers/array/creation/115522.cc: New test.

    (cherry picked from commit 510ce5eed69ee1bea9c2c696fe3b2301e16d1486)

Reply via email to