Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1011,10 +1011,17 @@ template bool ByteCodeExprGen::VisitCXXTemporaryObjectExpr( const CXXTemporaryObjectExpr *E) { - if (std::optional LocalIndex = allocateLocal(E, /*IsExtended=*/false)) { - return this->visitLocalInitializer(E, *LocalIndex); + if (!this->emitGetPtrLocal(*LocalIndex, E)) + return false; + + if (!this->visitInitializer(E)) + return false; + + if (DiscardResult) + return this->emitPopPtr(E); + return true; } return false; } Index: clang/test/AST/Interp/records.cpp =================================================================== --- clang/test/AST/Interp/records.cpp +++ clang/test/AST/Interp/records.cpp @@ -880,3 +880,18 @@ } } +namespace TemporaryObjectExpr { + struct F { + int a; + constexpr F() : a(12) {} + }; + constexpr int foo(F f) { + return 0; + } + /// FIXME: This should also work in C++14, but it needs suport for + /// CXXConstructExpr. I think. +#if __cplusplus > 201402L + static_assert(foo(F()) == 0, ""); +#endif + +}