Consider this example:
class A
{
void foo();
public:
void bar();
};
template <class> class B
{
B()
{
A a;
a.foo(); // 1
A::bar(); // 2
a.bar(1); // 3
}
};
Note B
is never instantiated.
clang++
reports all three marked lines as erroneous. g++
(4.8.3) accepts lines 1
and 2
and only reports line 3
.
If B
is instantiated, g++
happily reports all three lines as erroneous.
Is this a g++
bug? One would think so. A
is not a dependent name and its members should be checked normally at template definition time. Are there nuances I don't see?