Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2105,7 +2105,18 @@ template bool ByteCodeExprGen::VisitCXXDefaultArgExpr( const CXXDefaultArgExpr *E) { - return this->visit(E->getExpr()); + const Expr *SubExpr = E->getExpr(); + + if (std::optional T = classify(E->getExpr())) + return this->visit(SubExpr); + + if (std::optional LocalIndex = + allocateLocal(SubExpr, /*IsExtended=*/true)) { + if (!this->emitGetPtrLocal(*LocalIndex, E)) + return false; + return this->visitInitializer(SubExpr); + } + return false; } template Index: clang/test/AST/Interp/records.cpp =================================================================== --- clang/test/AST/Interp/records.cpp +++ clang/test/AST/Interp/records.cpp @@ -879,3 +879,27 @@ } } +namespace CompositeDefaultArgs { + struct Foo { + int a; + int b; + constexpr Foo() : a(12), b(13) {} + }; + + class Bar { + public: + bool B = false; + + constexpr int someFunc(Foo F = Foo()) { + this->B = true; + return 5; + } + }; + + constexpr bool testMe() { + Bar B; + B.someFunc(); + return B.B; + } + static_assert(testMe(), ""); +}