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

--- Comment #1 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:4d26b4cc14c1db94062240a69bffdbe3e2aa5904

commit r17-3716-g4d26b4cc14c1db94062240a69bffdbe3e2aa5904
Author: Wang Jinghao <[email protected]>
Date:   Sat Aug 15 04:42:00 2026 +0800

    c++/contracts: always regenerate contracts from template [PR125712]

    `tsubst_function_decl()' associates uninstantiated contracts with a
    function template instantiation.  If an explicit instantiation is
    encountered before a later redeclaration provides the definition,
    those contracts can still refer to PARM_DECLs from the earlier
    declaration.

    Therefore, we should always regererate the contracts from the current
    code_pattern in `regenerate_decl_from_template()' when either DECL
    or pattern has contracts.

            PR c++/125712

    gcc/cp/ChangeLog:

            * pt.cc (regenerate_decl_from_template): Regenerate contracts
            from the current code pattern.

    gcc/testsuite/ChangeLog:

            * g++.dg/contracts/cpp26/specialization-pr125712.C: New test.

    Signed-off-by: Wang Jinghao <[email protected]>

Reply via email to