Created attachment 27595 [details] testcase The error occurs when there is at one template argument with default and one without. Errors are generated for local structs, classes, unions and lambda functions. For the attached usecase I get with gcc 4.6.3 and 4.7.0: C:\dev\projects\compiler test>g++ gcc_test2.cpp --std=c++0x -fsyntax-only gcc_test2.cpp: In function 'void Foo(T)': gcc_test2.cpp:5:12: error: no default argument for 'T'
>gcc_test2.cpp:5:12: error: no default argument for 'T' It is not rejecting the local type but rather it is rejecting the second template argument which does not have a default argument even though the first argument does.
Their is no requirement (in the c++11 standard) for function templates that implies subsequent template parameters after a template parameter with default template argument must also have default template arguments (in contrast to class templates). In general this works in gcc. But with the local types inside the template function gcc might reject it because it creates local types as templated with the same template parameters/default arguments and checks the requirement for class templates. The line number/offset in the error message clearly refers to the local struct.
Oh I see. The trunk shows what is going on better: t.cc: In function ‘void Foo(T)’: t.cc:4:12: error: no default argument for ‘T’ struct X {}; ^
*** Bug 54104 has been marked as a duplicate of this bug. ***
Looking into it.
Author: paolo Date: Tue Jul 31 09:46:46 2012 New Revision: 190001 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190001 Log: /cp 2012-07-31 Paolo Carlini <paolo.carlini@oracle.com> PR c++/53624 * pt.c (check_default_tmpl_args): Don't check local types. /testsuite 2012-07-31 Paolo Carlini <paolo.carlini@oracle.com> PR c++/53624 * g++.dg/cpp0x/temp_default5.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/temp_default5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed.