- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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() { Foo(1.0); }
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
Judy
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I will forward this issue to microsoft

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page