struct B
{
int a;
void foo() {a = 5;}
};
template <typename T>
struct A
{
A(int i) { B::foo(); }
A(double d) {}
};
int main()
{
A<int> a(5.0);
}
gcc 4.7.2 compiles it without errors. clang 3.4svn complains:
$ clang -Wall -Wextra test.cpp
test.cpp:10:16: error: call to non-static member function without an object argument
A(int i) { B::foo(); }
~~~^~~
Of course the code is wrong, but which compiler is conformant with the standard?
It's also strange that clang doesn't print any 'in instantiation' note like gcc does if you use 5 instead of 5.0:
$ gcc test.cpp
test.cpp: In instantiation of ‘A<T>::A(int) [with T = int]’:
test.cpp:15:12: required from here
test.cpp:9:13: error: cannot call member function ‘void B::foo()’ without object