title: Why does the /Zc:twoPhase- compiler switch has no effect in MSVC?
body: <p>Why doesn't the <code>/Zc:twoPhase-</code> compiler switch which follows the <code>/permissive-</code> switch cause the compilation errors to disappear in MSVC 19.13, just like they disappear when the /permissive-` switch is completely removed, with the following problem code ?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  template &lt;unsigned int BYTES&gt;
  class CBase
  {
  public:
      char Arr[BYTES];
  
      int Fn1(void) {
          return Arr[1] ^ Arr[sizeof(Arr)-1];
      }
  
      int Fn2(void) {
          return Arr[2] ^ Arr[sizeof(Arr)-2];
      }
  };
  
  template &lt;unsigned int BYTES&gt;
  class CDerived : public CBase&lt;BYTES&gt;
  {
  public:
  
      int FnSum(void) {
          return Fn1() + Fn2() + Arr[0];  // ERRORs: identifiers "Fn1" and "Fn2" and "Arr" are NOT found !
      }
  };    
  
  int main(void)
  {
      CDerived&lt;32&gt; ddd;
  
      printf("%d\n", ddd.Fn1());  //No error here
      printf("%d\n", ddd.Fn2());  //No error here
      printf("%d\n", ddd.FnSum());
  
      return (int)ddd.Arr[0];   //No error here
  }
  </code></pre>
  
  <p>The above code compiles in MSVC v19.10 when the <code>/permissive-</code> switch is completely removed.<br>
  See:  <a href="https://godbolt.org/g/Yxw89Y" rel="nofollow noreferrer">https://godbolt.org/g/Yxw89Y</a></p>
  
  <p><em>NOTE: I cannot include a link to an example on <a href="http://godbolt.org" rel="nofollow noreferrer">http://godbolt.org</a> with the <code>/permissive- /Zc:twoPhase-</code> switches together, because the latest Godbolt MSVC compiler (v19.10) is outdated and does not support the <code>/Zc:twoPhase-</code> compiler switch.</em></p>
  
  <p>According to <strong><a href="https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase" rel="nofollow noreferrer">this article</a></strong> and <strong><a href="https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase-name-lookup-support-comes-to-msvc/" rel="nofollow noreferrer">this article</a></strong>, the compilation error in MSVC comes from the Two-Phase Name Lookup being enabled by the conformance to the C++ standard mode ( enabled by the <code>/permissive-</code> option).<br>
  Also, according to the <a href="https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase-name-lookup-support-comes-to-msvc/" rel="nofollow noreferrer">former article</a>: "<em>The <code>/permissive-</code> option implicitly sets the conforming two-phase lookup compiler behavior, but it can be overridden by using <code>/Zc:twoPhase-</code> switch</em>".<br>
  However adding the two compiler switches <code>/permissive- /Zc:twoPhase-</code> (in that order) does not override it and does not make the compilation errors disappear in MSVC v19.13.</p>
  
  <p>For the Context of this problem, see <strong><a href="https://stackoverflow.com/questions/50321788/a-better-way-to-avoid-public-member-invisibility-and-source-code-bloat-repetitio">this entry</a></strong>.</p>