[LLVMbugs] [Bug 20890] New: Variadic template function fails to match forward-declared template with default values
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Sep 9 15:46:57 PDT 2014
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: unassignedbugs at nondot.org
Reporter: schrodingersbox at gmail.com
CC: llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140909/a388c745/attachment.html>
More information about the llvm-bugs
mailing list