I've tested 4 compilers:
- VC++14
- Clang 3.9
- g++ 6.0
- Clang/C2 (VS2015 bundle)
The results differ. I list the compilers that accept the code in the comment followed.
struct S
{
void mf() {}
};
template<class T>
void fun(T dependent)
{
non_existent_var = 5; // 1, 4
non_existent_f(5); // 1, 4
S s;
s.non_existent_mf(); // 1, 4
s.mf(5); // 1, 4
non_existent_f(dependent); // 1, 2, 3, 4
s.non_existent_mf(dependent); // 1, 4
s.mf(dependent); // 1, 2, 3, 4
}
I'm a little surprised that Clang/C2 compiles differently than its official counterpart, maybe it tries to mimic MSVC...
Is the compiler required to do semantic analysis like name-lookup, overloading resolution, etc in template ?