[Bug c++/125011] ICE in tsubst at cp/pt.cc:17105 when using variable template in post contract of function template (-fcontracts)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 28 00:37:54 GMT 2026
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 <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:58f3920e31f3c436e1d6f9cbd2e2c93c152cc35a
commit r17-3717-g58f3920e31f3c436e1d6f9cbd2e2c93c152cc35a
Author: Wang Jinghao <zheng.xianyuwang@gmail.com>
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 <zheng.xianyuwang@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list