[LLVMbugs] [Bug 10069] New: Clang incorrectly reports substitution failure with default template arguments in function template
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jun 2 13:14:38 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10069
Summary: Clang incorrectly reports substitution failure with
default template arguments in function template
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: compile-fail
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jbytheway+llvm at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
This is a case reduced from code in libstdc++ (as shipped with gcc 4.5.2).
The following code, which I believe is valid:
template<typename T, T a, T b=0, T c=1>
T f(T x)
{
return x;
}
int main()
{
f<unsigned int, 0>(0);
return 0;
}
generates the following error when given to clang++ -std=gnu++0x:
template-int.cpp:9:3: error: no matching function for call to 'f'
f<unsigned int, 0>(0);
^~~~~~~~~~~~~~~~~~
template-int.cpp:2:3: note: candidate template ignored: substitution failure
[with T = unsigned int, a = 0, b = 0]
T f(T x)
^
1 error generated.
gcc 4.5.2 accepts this code. Note that if you replace 'unsigned int' by just
'int' then it compiles fine. Also, if the fourth template argument of f is
removed, then it compiles fine.
$ clang++ --version
clang version 3.0 (trunk 132479)
Target: x86_64-unknown-linux-gnu
Thread model: posix
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list