<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 crash on invalid with sizeof undeduced auto type"
   href="https://llvm.org/bugs/show_bug.cgi?id=28116">28116</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang crash on invalid with sizeof undeduced auto type
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Frontend
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat test.cpp 
struct S {
  template <typename T> struct M;

  template <typename T>
  typename M<T>::D operator-(const T& other) const { }

  template <typename T>
  struct M {
    static_assert(sizeof(T) == -1, "");
  };
};

struct I {
  const S& Get() const;
};

template<typename T1>
T1 F(T1 v1, T1 v2);

void Foo(const I& i) {
  auto R = i.Get();
  auto w_W = F(R, R_W);
  auto Z = 0.5 * (R - R_W);
}
$ clang test.cpp -std=c++11
test.cpp:22:19: error: use of undeclared identifier 'R_W'
  auto w_W = F(R, R_W);
                  ^
clang: ../tools/clang/lib/AST/ASTContext.cpp:1773: clang::TypeInfo
clang::ASTContext::getTypeInfoImpl(const clang::Type *) const: Assertion
`!A->getDeducedType().isNull() && "cannot request the size of an undeduced or
dependent auto type"' failed.

It looks like S::M<T> gets instantiated with T being an undeduced auto type. 
The static_assert then attempts to evaluate sizeof(T), causing the crash.</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>