(c++11) template non dependent name binding issues

(c++11) template non dependent name binding issues


According to the C++11 specification (in my case I refer to draft n3376), non dependent name found at template declaration should be bound at point of declaration. Here is quotation from standard:

14.6 Name resolution

..."If a name does not depend on a template-parameter (as defined in 14.6.2), a declaration (or set of declarations) for that name shall be in scope at the point where the name appears in the template definition; the name is bound to the declaration (or declarations) found at that point and this binding is not affected by declarations that are visible at the point of instantiation."

Consider following example:

#include <iostream>
using namespace std;

static void g(double) {
	cout << "double" << endl;

template<typename T> void Foo(T t){
	g(0); // not dependent name, expecting it will be resolved at point of declaration
	g(t); // dependent name, expecting it will be resolved at point of instantiation


static void g(int) {
	cout << "int" << endl;

void TemplateNameResolution() {

With my understanding of standard I expect it will output: double, double

But actually it output: int, double.

Am I wrong?

I'm using Intel® C++ Composer XE 2015.


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply


You must be using our Windows compiler. On Linux the result is as you expected. We emulate the Microsoft compiler on Windows which does not conform to the standard in this regard. The /Qstd=c++11 switch just enables some additional c++11 features it doesn't make the compiler follow the standard in a strict manner. If it did, the iostream header on Windows would not compile correctly...



Thanks, I will forward this issue to  microsoft

Leave a Comment

Please sign in to add a comment. Not a member? Join today