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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

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

commit r15-9226-gf60570b26446781c0205981804f6aa4ff1708b12
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Apr 5 15:22:48 2025 -0400

    c++: harmless use of 'this' rejected despite P2280R4 [PR118249]

    Here the implicit use of 'this' in inner.size() template argument was
    being rejected despite P2280R4 relaxations, due to the special *this
    handling in the INDIRECT_REF case of potential_constant_expression_1.

    This handling was originally added by r196737 as part of fixing PR56481,
    and it seems obsolete especially in light of P2280R4.  There doesn't
    seem to be a good reason that we need to handle *this specially from
    other dereferences.

    This patch therefore removes this special handling.  As a side benefit
    we now correctly reject some *reinterpret_cast<...>(...) constructs
    earlier, via p_c_e_1 rather than via constexpr evaluation (because the
    removed STRIP_NOPS step meant we'd overlook such casts), which causes a
    couple of diagnostic changes (for the better).

            PR c++/118249

    gcc/cp/ChangeLog:

            * constexpr.cc (potential_constant_expression_1)
            <case INDIRECT_REF>: Remove obsolete *this handling.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-reinterpret2.C: Expect error at
            call site of the non-constexpr functions.
            * g++.dg/cpp23/constexpr-nonlit12.C: Likewise.
            * g++.dg/cpp0x/constexpr-ref14.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to