Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -394,10 +394,9 @@ return true; } + const Expr *Init = VD->getInit(); // Integers, pointers, primitives. if (Optional T = this->classify(VD->getType())) { - const Expr *Init = VD->getInit(); - unsigned Offset = this->allocateLocalPrimitive(VD, *T, VD->getType().isConstQualified()); // Compile the initializer in its own scope. @@ -412,8 +411,11 @@ } // Composite types - allocate storage and initialize it. - if (Optional Offset = this->allocateLocal(VD)) - return this->visitLocalInitializer(VD->getInit(), *Offset); + if (Optional Offset = this->allocateLocal(VD)) { + if (Init) + return this->visitLocalInitializer(Init, *Offset); + return true; + } return this->bail(VD); } Index: clang/test/AST/Interp/cxx20.cpp =================================================================== --- clang/test/AST/Interp/cxx20.cpp +++ clang/test/AST/Interp/cxx20.cpp @@ -70,6 +70,11 @@ } static_assert(initializedLocal() == 20); +constexpr void uninitializedLocalArray() { + int a[]; // expected-error {{needs an explicit size or an initializer}} \ + // ref-error {{needs an explicit size or an initializer}} +} + #if 0 // FIXME: This code should be rejected because we pass an uninitialized value // as a function parameter.