Summary: | [C++11] Variadic template specialisation fails | ||
---|---|---|---|
Product: | gcc | Reporter: | Seth Carnegie <sethcarnegie> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | daniel.kruegler |
Priority: | P3 | Keywords: | rejects-valid |
Version: | 4.7.1 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | 4.8.0 | |
Known to fail: | Last reconfirmed: | 2012-06-19 00:00:00 | |
Attachments: | Example code |
Also you might want to know that Clang 3.2 accepts the code. There was a StackOverflow question about it here: http://stackoverflow.com/a/11069116/726361 Confirmed, I think this should be accepted. I disaqree. IMO the example shall be ill-formed and it does not match the referenced stackoverflow example. The specialization template<> int foo<int>(); does not match the primary template template<typename T, typename... Args> int foo(T, Args...); because it omits the first function argument depending on template parameter T. The fixed version would be written as: template<typename T, typename... Args> int foo(T, Args...); template<> int foo<int>(int) { return 0; } int main() { } and this example is accepted by gcc 4.8 HEAD. Unless gcc 4.7.1 does need to be fixed, this seems an invalid bug report to me. Oops, well spotted, thanks, Daniel. I think this is a dup of PR 38543 then, although that says it's fixed in 4.7.1 Indeed it does work with 4.7.1 so it's a dup. (This is why http://gcc.gnu.org/bugs/ asks for the output of 'gcc -v' because you aren't actually using the version you claim to be using.) *** This bug has been marked as a duplicate of bug 38543 *** Actually I was using 4.7.1 and I did use g++ -v, I just made a mistake in simplifying the code from the stackoverflow example. I compiled the simplification with 4.7.1 but the SO example with 4.7 and assumed it was the same error (since the error message was exactly the same). |
Created attachment 27656 [details] Example code The code in the attached file, which should compile, does not. It fails with the error: test.cpp:6:5: error: template-id 'foo<int>' for 'int foo()' does not match any template declaration I compiled with the following command line: g++ test.cpp -std=c++11 -Wall -Wextra -fno-strict-aliasing -fwrapv