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

--- Comment #3 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:afe83e26073375fc95a6e92e760925c25a2d979a

commit r17-7005-gafe83e26073375fc95a6e92e760925c25a2d979a
Author: Sendao Yan <[email protected]>
Date:   Tue Dec 1 17:13:41 2026 -0500

    c++/129187: Keep imported deduced type of variable template

    When a header is textually included in a module's global module fragment
    and again in a TU that imports that module, a variable template with an
    auto-deduced type is redeclared in the importing TU before its placeholder
    type is deduced.  The imported declaration already has a deduced type, so
    decls_match rejects the pair and the new declaration shadows the imported
    one.  An alias template whose type uses the variable template then
    compares unequal against the imported alias declaration and is rejected
    as a conflicting declaration.

    Handle TEMPLATE_DECLs whose result is a VAR_DECL like plain VAR_DECLs in
    duplicate_decls: when the imported declaration already has a deduced type,
    keep it instead of pushing the undeduced redeclaration.

            PR c++/129187

    gcc/cp/ChangeLog:

            * decl.cc (duplicate_decls): Keep an imported variable template
with
            a deduced type when it is redeclared with an undeduced placeholder.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/auto-10.h: New test.
            * g++.dg/modules/auto-10_a.C: New test.
            * g++.dg/modules/auto-10_b.C: New test.

    Signed-off-by: Sendao Yan <[email protected]>

Reply via email to