User account creation filtered due to spam.

Bug 53723 - [C++11] Variadic template specialisation fails
Summary: [C++11] Variadic template specialisation fails
Status: RESOLVED DUPLICATE of bug 38543
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-06-19 17:10 UTC by Seth Carnegie
Modified: 2012-06-20 20:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.0
Known to fail:
Last reconfirmed: 2012-06-19 00:00:00


Attachments
Example code (100 bytes, text/plain)
2012-06-19 17:10 UTC, Seth Carnegie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Seth Carnegie 2012-06-19 17:10:16 UTC
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
Comment 1 Seth Carnegie 2012-06-19 17:16:03 UTC
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
Comment 2 Jonathan Wakely 2012-06-19 17:32:01 UTC
Confirmed, I think this should be accepted.
Comment 3 Daniel Krügler 2012-06-20 12:26:27 UTC
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.
Comment 4 Jonathan Wakely 2012-06-20 12:47:53 UTC
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
Comment 5 Jonathan Wakely 2012-06-20 13:01:09 UTC
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 ***
Comment 6 Seth Carnegie 2012-06-20 20:27:25 UTC
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).