Search

Errors C2950 and C3416 are the same and shouldn't be errors at the first place. by Cassio Neri

Closed

1
0
Sign in
to vote
Type: Bug
ID: 753981
Opened: 7/16/2012 4:52:14 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The errors C2950 and C3416 are, basically, the same:

error C2950: cannot explicitly instantiate an explicit specialization
error C3416: an explicit specialization may not be explicitly instantiated

The only difference is that the former happens with templates classes and the latter with template functions. The code in the "Steps to reproduce section" raises both of them. Nevertheless, this redundancy is not the main issue. Quoting 14.7.2/5:

"For a given set of template parameters, if an explicit instantiation of a template appears after a declaration of an explicit specialization for that template, the explicit instantiation has no effect."

It's worth mentioning that GCC 4.6.3 and Clang 3.1 compile the code with no issue.

I reckon that the issue raised by C2950 and C3416 is important and developers might wanted to be warned abou it. My suggestion is turning the errors into a single (one code and one message) warning. In addition, because the standard says that explicit instantiating a specialization has "no effects", the warning should be turned off by default.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012 RC

Steps to reproduce

//--- Class ---//

// Template:
template <typename> struct Foo {};

// Specialization:
template <> struct Foo<int> {};

// Explicit instantiation of specialization (raises C2950 but it shouldn't):
template struct Foo<int>;

//--- Function ---//

// Template:
template <typename> void bar() { }

// Template specialization
template <> void bar<int>() { }

// Explicit instantiation of specialization (raises C3416 but it shouldn't):
template void bar<int>();

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Errors C2950 and C3416

Expected results

No compile errors.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/9/2012 at 1:20 PM
Hi Cassio:
    Thanks for reporting the issue.
    I can confirm that this is compiler bug (the errors were added when we fixed several compiler crashes).
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 7/16/2012 at 7:55 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Microsoft Visual Studio Connect Support Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 7/16/2012 at 5:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.