diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -1831,6 +1831,8 @@ auto *CXXRD = ElementType->getAsCXXRecordDecl(); if (!CXXRD) return false; + if (!CXXRD->isCompleteDefinition()) + return false; CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD); SemaRef.CheckDestructorAccess(Loc, Destructor, diff --git a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp --- a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -133,3 +133,11 @@ namespace PR24816 { struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}} } + +namespace no_crash { +template +class Foo {}; +void test(int foo) { + Foo array[foo] = {0}; // expected-error {{variable-sized object may not be initialized}} +} +}