Ah.. I understand.. so this isn't about the STL implementation that comes with GCC vs. VC, but the compiler himself?
Let me construct something and explain it using my own words, to test whether I got the point. ;).
I made some simplification (and tested it with VC and gcc to get a grasp on who's right here):
1 2 3 4 5 6
|
// compiles in VC, doesn't compile in gcc
template<class X>
struct Foo { typedef int foo; };
template<class Y>
struct Bar { void bar() { Foo<Y>::foo x; } };
|
Since the template is never instantiated, it must only be checked for malformed syntax. As you said, the problem is with the syntax, as Foo<Y>::foo could be a function and then bar() is completely ill-formed.
gcc does this syntax checking of unused templates, whereas VC seem to not do it. If you actually use Bar somewhere, you get an error in VC as expected:
1 2 3 4 5 6 7 8 9 10 11
|
// doesn't compile anywhere
template<class X>
struct Foo { typedef int foo; };
template<>
struct Foo<int> { void foo(){} };
template<class Y>
struct Bar { void bar(){ Foo<Y>::foo x; } };
int main() { Bar<int>().bar(); }
|
Bad Microsoft! No dinner today! ;)
I still like VC's attitude more. :-D
Thanks for dragging me along, Bazzy.
Ciao, Imi.
Edit: Yikes! Seems like VC does practically no checking of any template-function if the template is not intantiated..
template<class T> struct A { void a() { -.!""& Moo! } };
compiles just fine. :-O