Compiler Warning (level 4) C4347
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 4) C4347

Error Message

behavior change: 'function template' is called instead of 'function'

In Visual Studio .NET, if you had a template function and a nontemplate function with the same name as the template function, the compiler incorrectly treated the nontemplate function as a specialization of the template function.

For code that works the same in all versions of Visual C++, add template<> above the nontemplate function, making it a real explicit specialization.

For more information, see Summary of Compile-Time Breaking Changes.

This warning is off by default. For more information, see Compiler Warnings That Are Off by Default.


The following sample generates C4347.

// C4347.cpp
// compile with: /W4 /EHsc
#pragma warning (default : 4347)

template <typename T>
void f(T t) { T i = t; i = 0; }

void f(int i) { i++; }

// OK
template <typename T>
void f2(T t) { T i = t; i = 0; }

template <>
void f2(int i) { i++; }

int main() {
   f(5);   // regular function call
   f<int>(5);   // C4347 calls implicit instantiation

© 2015 Microsoft