For the testcase template<typename T> void foo(T); void bar() { struct A a; foo(a); } the we get the following error message since GCC 3.4.0: bug.cc: In function 'void bar()': bug.cc:5: error: aggregate 'A a' has incomplete type and cannot be defined bug.cc:6: error: no matching function for call to 'foo(<type error>)' Although not completely bogus, the last line is not very helpful here. Since "a" has error_mark_node as type, overload resolution just won't work. In fact we shouldn't perform overload analysis here at all IMHO. Patch under way.
Subject: Bug 23965 CVSROOT: /cvs/gcc Module name: gcc Changes by: reichelt@gcc.gnu.org 2005-09-21 15:34:42 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog gcc/testsuite/g++.dg/template: error1.C Log message: PR c++/23965 * call.c (resolve_args): Return error_mark_node on arguments whose TREE_TYPE is error_mark_node. * g++.dg/template/error1.C: Reject "no matching function" message. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4898&r2=1.4899 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.552&r2=1.553 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6091&r2=1.6092 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Subject: Bug 23965 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: reichelt@gcc.gnu.org 2005-09-21 15:39:53 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog gcc/testsuite/g++.dg/template: error1.C Log message: PR c++/23965 * call.c (resolve_args): Return error_mark_node on arguments whose TREE_TYPE is error_mark_node. * g++.dg/template/error1.C: Reject "no matching function" message. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.243&r2=1.3892.2.244 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.28&r2=1.452.2.29 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.437&r2=1.3389.2.438 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=1.1.22.1
Fixed on mainline and the 3.4 branch. Waiting for 4.0 branch to unfreeze.
Subject: Bug 23965 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: reichelt@gcc.gnu.org 2005-10-05 16:00:11 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog gcc/testsuite/g++.dg/template: error1.C Log message: PR c++/23965 * call.c (resolve_args): Return error_mark_node on arguments whose TREE_TYPE is error_mark_node. * g++.dg/template/error1.C: Reject "no matching function" message. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.117&r2=1.4648.2.118 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.531.2.8&r2=1.531.2.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.431&r2=1.5084.2.432 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error1.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1&r2=1.1.82.1
This is now fixed on the 4.0 branch, too. Unfortunately I committed a suboptimal version to the 3.4 branch and mainline: Misreading Mark's comments on the original patch I used if (arg == error_mark_node || error_operand_p (arg)) instead of if (error_operand_p (arg)) Since arg == error_mark_node is already checked in error_operand_p, the first test is superfluous. I'll keep the PR open until this is fixed.
The redundant check is now also fixed: http://gcc.gnu.org/ml/gcc-cvs/2005-10/msg00190.html http://gcc.gnu.org/ml/gcc-cvs/2005-10/msg00191.html