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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>:

https://gcc.gnu.org/g:0210bedf481a9fd248ce29650b824bcd84c3723c

commit r15-9136-g0210bedf481a9fd248ce29650b824bcd84c3723c
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Tue Apr 1 16:36:30 2025 +1100

    c++/modules: Forbid exposures of TU-local entities in inline variables
[PR119551]

    An inline variable has vague linkage, and needs to be conditionally
    emitted in TUs that reference it.  Unfortunately this clashes with
    [basic.link] p14.2, which says that we ignore the initialisers of all
    variables (including inline ones), since importers will not have access
    to the referenced TU-local entities to write the definition.

    This patch makes such exposures be ill-formed.  One case that continues
    to work is if the exposure is part of the dynamic initialiser of an
    inline variable; in such cases, the definition has been built as part of
    the module interface unit anyway, and importers don't need to write it
    out again, so such exposures are "harmless".

            PR c++/119551

    gcc/cp/ChangeLog:

            * module.cc (trees_out::write_var_def): Only ignore non-inline
            variable initializers.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/internal-5_a.C: Add cases that should be
            ignored.
            * g++.dg/modules/internal-5_b.C: Test these new cases, and make
            the testcase more robust.
            * g++.dg/modules/internal-11.C: New test.
            * g++.dg/modules/internal-12_a.C: New test.
            * g++.dg/modules/internal-12_b.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>

Reply via email to