Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -561,6 +561,9 @@ when an immediate invocation appears as a part of an expression that produces temporaries. (`#60709 `_). +- Fix use of direct-intialization over copy-initialization when using + = form of brace-or-equal-initialzer. This fixes + (`#63503 `_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -15441,8 +15441,8 @@ // C++11 5.17p9: // The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning // of x = {} is x = T(). - InitializationKind Kind = InitializationKind::CreateDirectList( - RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc()); + InitializationKind Kind = + InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc); InitializedEntity Entity = InitializedEntity::InitializeTemporary(LHSExpr->getType()); InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr); Index: clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp =================================================================== --- clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp +++ clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp @@ -283,3 +283,13 @@ F f4(const bool x) { return F{x}; } #endif } + +namespace GH62503 { +enum class E {E1}; + +void f() { + E e; + e = {E::E1}; + e = {0}; // expected-error {{cannot initialize a value of type 'E' with an rvalue of type 'int'}} +} +}