[llvm-bugs] [Bug 28116] New: Clang crash on invalid with sizeof undeduced auto type

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 13 18:20:43 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28116

            Bug ID: 28116
           Summary: Clang crash on invalid with sizeof undeduced auto type
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160614/c1c6e3f2/attachment-0001.html>


More information about the llvm-bugs mailing list