]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: unifying specializations of non-primary tmpls [PR120161]
authorPatrick Palka <ppalka@redhat.com>
Thu, 15 May 2025 15:07:53 +0000 (11:07 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 15 May 2025 15:07:53 +0000 (11:07 -0400)
commit0c430503f2849ebb20105695b8ad40d43d797c7b
tree77dfa4ff4ebc1509f9dcf5eea8026cde93b8c4d6
parent9a2083f025fae3559474b961943484d764c2e6dd
c++: unifying specializations of non-primary tmpls [PR120161]

Here unification of P=Wrap<int>::type, A=Wrap<long>::type wrongly
succeeds ever since r14-4112 which made the RECORD_TYPE case of unify
no longer recurse into template arguments for non-primary templates
(since they're a non-deduced context) and so the int/long mismatch that
makes the two types distinct goes unnoticed.

In the case of (comparing specializations of) a non-primary template,
unify should still go on to compare the types directly before returning
success.

PR c++/120161

gcc/cp/ChangeLog:

* pt.cc (unify) <case RECORD_TYPE>: When comparing specializations
of a non-primary template, still perform a type comparison.

gcc/testsuite/ChangeLog:

* g++.dg/template/unify13.C: New test.

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