http://llvm.org/bugs/show_bug.cgi?id=20890
Bug ID: 20890
Summary: Variadic template function fails to match
forward-declared template with default values
Product: new-bugs
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Created attachment 13014
--> http://llvm.org/bugs/attachment.cgi?id=13014&action=edit
Source file which fails to compile due to bug
A function with a variadic template template argument fails to match against a
template class whose default template arguments are forward-declared. For
example the following code fails to compile:
template<typename A, typename B> struct foo;
template<typename A, typename B=int> struct foo { };
template <template <typename, typename...> class Container>
void processVariadic(Container<double> /*elements*/) { }
int main() {
processVariadic(foo<double>{});
}
Compiling with 'clang++ -std=c++11 bug.cpp', the resulting error is:
bug.cpp:8:5: error: no matching function for call to 'processVariadic'
processVariadic(foo<double>{});
^~~~~~~~~~~~~~~
bug.cpp:5:6: note: candidate template ignored: substitution failure [with
Container = foo]:
too few template arguments for class template 'foo'
void processVariadic(Container<double> /*elements*/) { }
^ ~~~~~~~~~
1 error generated.
The compiler seems to look at the first declaration and expect foo to require
two template parameters, ignoring the later default parameter. If the default
parameter is instead put on the forward declaration, it compiles fine.
Both clang++ 3.6.0 (trunk) and Apple LLVM version 5.1 (clang-503.0.40) (based
on LLVM 3.4svn) fail to compile. GCC (g++ 4.9.1) is able to compile properly.
This issue occurs, for example, in the libc++ implementation of std::list.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs