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

--- Comment #7 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:58f3920e31f3c436e1d6f9cbd2e2c93c152cc35a

commit r17-3717-g58f3920e31f3c436e1d6f9cbd2e2c93c152cc35a
Author: Wang Jinghao <[email protected]>
Date:   Fri Aug 14 17:27:04 2026 -0400

    c++/contracts: rebuilding template postconditions [PR125011]

    `rebuild_postconditions' uses `tsubst_expr' to replace the
    placeholder result variable with one of the known return type.
    Passing an empty template argument vector causes direct references
    to template parameters in the condition to ICE in tsubst.

    If we're still in a template we shouldn't bother rebuilding at all; we'll
do
    it properly at instantiation time.

            PR c++/125011

    gcc/cp/ChangeLog:

            * contracts.cc (rebuild_postconditions): Skip if
            processing_template_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/contracts/cpp26/template-post-pr125011.C: New test.
            * g++.dg/contracts/cpp26/dcl.contract.func.p7-t1.C: Expect
            additional error.
            * g++.dg/contracts/cpp26/dcl.contract.func.p7-t2.C: Likewise.

    Signed-off-by: Wang Jinghao <[email protected]>
    Co-authored-by: Jason Merrill <[email protected]>

Reply via email to