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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

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

commit r17-498-gde3a3064f65bb52053d771fa44fb982e8ec80727
Author: Marek Polacek <[email protected]>
Date:   Tue May 12 17:01:29 2026 -0400

    c++/reflection: overzealous complete_type in consteval_only_p [PR125280]

    This bug report shows that we generate a bogus "has incomplete type"
    error for Element::mData in type12.C with -freflection: consteval_only_p
    attempts to complete Array when finishing mData, but mData uses Element
    which is currently being defined, so we can't complete it yet.  We could
    fix this bogus error by checking can_complete_type_without_circularity
    before calling complete_type in consteval_only_p, but I'm no longer so
    sure that we must call complete_type at all.  This patch removes that
    call.  One consequence of that is that we don't produce the "outside
    a constant-evaluated context" error for C::mData (only when mData is
    defined outside the class as with A::mData above).  This behavior
    matches clang++ though so I'm not too worried about it.

    type13.C shows that even without the complete_type we can still get
    to consteval_only_p_walker::walk with a member with erroneous type
    which currently crashes.

            PR c++/125280

    gcc/cp/ChangeLog:

            * reflect.cc (consteval_only_p): Don't complete_type.
            (consteval_only_p_walker::walk): Return false for
            error_mark_node.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/init19.C: New test.
            * g++.dg/reflect/type12.C: New test.
            * g++.dg/reflect/type13.C: New test.

    Reviewed-by: Patrick Palka <[email protected]>

Reply via email to