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

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

https://gcc.gnu.org/g:35b17c7713d4bd7a675ee8908724325e957d1482

commit r16-7204-g35b17c7713d4bd7a675ee8908724325e957d1482
Author: Jason Merrill <[email protected]>
Date:   Wed Jan 28 14:17:13 2026 +0800

    c++: defer DECL_ONE_ONLY vs consteval-only [PR122785]

    The failure in the given PR occurs because when setting up an
    imported vague-linkage variable, we currently call 'maybe_commonize_var'
    which for -freflection checks 'consteval_only_p'.  Unfortunately this
    latter function needs to call 'complete_type_p' which can perform
    recursive loading of the (possibly yet-to-be-streamed) class type,
    breaking modules assumptions.

    If we just remove the consteval_only_p early exit from maybe_commonize_var,
    we end up crashing at EOF while trying to mangle its comdat group, so we
    need to undo maybe_commonize_var along with setting DECL_EXTERN.

            PR c++/122785

    gcc/cp/ChangeLog:

            * decl.cc (maybe_commonize_var): Don't check consteval_only_p.
            (make_rtl_for_nonlocal_decl): Undo make_decl_one_only for
            consteval-only variables.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/reflect-1_a.H: New test.
            * g++.dg/modules/reflect-1_b.C: New test.

    Co-authored-by: Nathaniel Shead <[email protected]>

Reply via email to