Normal function defines a declared-only template function. - by Cassio Neri

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 808135 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/8/2013 4:43:43 PM
Access Restriction Public


The program below shouldn't link (it doesn't with gcc 4.8.1, clang 3.3 and icc 13.1.3)

template <typename T>
void f(T);

int main() { f<int>(0); }

void f(int) {}


The compiler is seeing the definition of 'void f(int)' as that of 'void f<int>(int)'.

My guess is that both functions have the same signature but they shouldn't. Indeed, 1.3.18 gives that return type and template parameter list are part of a function template signature but 1.3.17 exclude those from a normal function's.
Sign in to post a comment.
Posted by Microsoft on 12/12/2013 at 12:52 PM
Hi Cassio:
    Thanks for reporting the issue. This behavior was actually added for backward-compabitily and our internal code base (like Windows) still relies on this.
    In VC7 and prior, normal function and function template specialization with the same signature have the same decorated name. The problem was fixed in VC7.1 and this behavior was added at that time. It is mainly used in the case where you can't change the existing exports of your dll.
    I checked in a fix to remove this behavior (but added a hidden switch for internal usage). The fix should show up in the next major release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 11/10/2013 at 7:23 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 11/8/2013 at 4: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(