]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: fix ICE when comparing targs [PR119580]
authorMarek Polacek <polacek@redhat.com>
Tue, 18 Nov 2025 20:23:20 +0000 (15:23 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 19 Nov 2025 17:42:44 +0000 (12:42 -0500)
commite2faea35a1edf6fca4d98800a1d9566db04a133b
treec968e3872386ec18a6553fa9d34a4454fcab1cbc
parent74bcef9f528c7d5bd89e5bee96bca7bddd89e9c8
c++: fix ICE when comparing targs [PR119580]

In r10-7816, cp_tree_equal/TEMPLATE_ID_EXPR was changed to use
comp_template_args to compare the targs.  This makes sense, but
comp_template_args won't deal with an error_mark_node.  We created
a BASELINK for S::foo<T::value_type>, but since value_type couldn't
be looked up, we ended up with an error_mark_node instead of a TREE_VEC
of arguments for the TEMPLATE_ID_EXPR in the BASELINK.

It seems reasonable not to create such a TEMPLATE_ID_EXPR by checking
the result of tsubst_template_args like we do in so many other places.
This changes the diagnostic in three tests, but it's only the followup
error message after complaining about the type/value mismatch.

PR c++/119580

gcc/cp/ChangeLog:

* pt.cc (tsubst_baselink): Return error_mark_node if
tsubst_template_args returned error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/template/crash106.C: Adjust expected diagnostics.
* g++.dg/template/crash112.C: Likewise.
* g++.dg/template/dependent-args1.C: Likewise.
* g++.dg/cpp0x/pr119580.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp0x/pr119580.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash106.C
gcc/testsuite/g++.dg/template/crash112.C
gcc/testsuite/g++.dg/template/dependent-args1.C