<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 (possibly) legal code"
   href="https://llvm.org/bugs/show_bug.cgi?id=25266">25266</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to compile (possibly) legal code
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hyrosen@mail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Here's a bit of code which clang 3.7 doesn't compile:


template <class T> struct R { static T& r(); };
struct M {
    static char m(M&);
    template <class T>
    static int m(const T&);
};
template <class T> struct A;
template <class T>
struct B {
    struct U { };
    struct V { M& operator, (U) const; };
    enum { v = sizeof(M::m((R<V>::r(), R<A<T>*>::r()))) };
};
template <class T> struct A { B<T> y; };
int main()
{
//  A<int>();  // Works if uncommented.
    B<int>();
}


Clang reports
h.cpp:14:36: error: field has incomplete type 'B<int>'
template <class T> struct A { B<T> y; };
                                   ^
h.cpp:12:38: note: in instantiation of template class 'A<int>' requested here
    enum { v = sizeof(M::m((R<V>::r(), R<A<T>*>::r()))) };
                                     ^
h.cpp:18:5: note: in instantiation of template class 'B<int>' requested here
    B<int>();
    ^
h.cpp:9:8: note: definition of 'B<int>' is not complete until the closing '}'
struct B {
       ^
1 error generated.

If I uncomment the marked line, clang compiles the code.  I don't know why the
compiler wants A<T> to be complete when it's just dealing with A<T>*, or why
uncommenting the marked line helps.</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>