<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang fails to compile valid template for x86_64-pc-windows-msvc target"
   href="https://bugs.llvm.org/show_bug.cgi?id=52420">52420</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to compile valid template for x86_64-pc-windows-msvc target
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>epastor@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Originally reported by Anthony Erlinger:

The following valid code fails to compile with -target x86_64-pc-windows-msvc:

template <typename A>
struct S {
    void f() {
        const int B = 5;
        struct C {
            int g() {
                return B; // <-- error: use of undeclared identifier 'B'
            }
        };
    }
};

void test() {
    S<int>().f();
}

Invocation: clang -target x86_64-pc-windows-msvc example.cc

Compiler output:
<source>:7:24: error: use of undeclared identifier 'B'
                return B;
                       ^
<source>:14:14: note: in instantiation of member function 'S<int>::f' requested
here
    S<int>().f();
1 error generated.
Compiler returned: 1

Godbolt example showing failure in clang vs successful compile in MSVC:
<a href="https://godbolt.org/z/h6431Wbh5">https://godbolt.org/z/h6431Wbh5</a>

This is fixed with the flags /Zc:twoPhase or -fno-delayed-template-parsing, but
works in MSVC itself, so it's clearly a bug in how we emulate MSVC's
non-compliant template instantiation.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>