2

I've tested 4 compilers:

  1. VC++14
  2. Clang 3.9
  3. g++ 6.0
  4. 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 ?

Richard Dally
  • 1,432
  • 2
  • 21
  • 38
Jamboree
  • 5,139
  • 2
  • 16
  • 36
  • My understanding from [this](http://blogs.msdn.com/b/vcblog/archive/2015/12/04/introducing-clang-with-microsoft-codegen-in-vs-2015-update-1.aspx) is that `Clang/C2` is just using `clang` to parse the code, it still uses `VS2015` to compile it so the behaviour should be the same as VS – EdChum Feb 01 '16 at 09:21
  • 1
    Related to [two-phase-lookup-explanation-needed](http://stackoverflow.com/questions/7767626/two-phase-lookup-explanation-needed) – Jarod42 Feb 01 '16 at 09:23
  • 3
    See the accepted answer to [this question](http://stackoverflow.com/questions/24933592/certain-errors-in-uninstantiated-template-not-reported-by-g) – Ami Tavory Feb 01 '16 at 09:24

0 Answers0