Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -94,6 +94,9 @@ // Classify the return type. ReturnType = this->classify(F->getReturnType()); + // Scope needed for the initializers. + BlockScope Scope(this); + // Constructor. Set up field initializers. if (const auto Ctor = dyn_cast(F)) { const RecordDecl *RD = Ctor->getParent(); Index: clang/test/AST/Interp/records.cpp =================================================================== --- clang/test/AST/Interp/records.cpp +++ clang/test/AST/Interp/records.cpp @@ -252,6 +252,26 @@ constexpr S s; static_assert(s.m() == 1, ""); +namespace InitializerTemporaries { + class Bar { + private: + int a; + + public: + constexpr Bar() : a(10) {} + constexpr int getA() const { return a; } + }; + + class Foo { + public: + int a; + + constexpr Foo() : a(Bar().getA()) {} + }; + constexpr Foo F; + static_assert(F.a == 10, ""); +} + #if __cplusplus >= 201703L namespace BaseInit { class _A {public: int a;};