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

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

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

commit r12-1844-gb7a89c041aa1d67654f1ba7b2839e221c3e14748
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Jun 28 12:59:19 2021 +0100

    libstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]

    PR libstdc++/101236 shows that LLVM depends on being able to use
    unique_ptr<T[]>::operator[] when T is incomplete. This is undefined, but
    previously worked with libstdc++. When I added the conditional noexcept
    to that operator we started to diagnose the incomplete type.

    This change restores support for that case, by making the noexcept
    condition check that the type is complete before checking whether
    indexing on the pointer can throw.  A workaround for PR c++/101239 is
    needed to avoid a bogus error where G++ fails to do SFINAE on the
    ill-formed p[n] expression and gets an ICE. Instead of checking that the
    p[n] expression is valid in the trailing-return-type, we only check that
    the element_type is complete.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101236
            * include/bits/unique_ptr.h (unique_ptr<T[], D>::operator[]):
            Fail gracefully if element_type is incomplete.
            * testsuite/20_util/unique_ptr/cons/incomplete.cc: Clarify that
            the standard doesn't require this test to work for array types.
            * testsuite/20_util/unique_ptr/lwg2762.cc: Check that incomplete
            types can be used with array specialization.
            * testsuite/20_util/unique_ptr/101236.cc: New test.

Reply via email to