[PATCH] D153375: [Clang] Fix incorrect use of direct initialization with copy initialization

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 16:27:36 PDT 2023


shafik added inline comments.


================
Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp:293
+  e = {E::E1};
+  e = {0}; // expected-error {{cannot initialize a value of type 'E' with an rvalue of type 'int'}}
+}
----------------
rsmith wrote:
> This looks valid to me. The language rules say we treat this as `e = E{0};`, which we accept.
Richard and I discussed this and I agree that based on http://eel.is/c++draft/expr.ass#8.1 this should be the same as `e = E{0}` and this would be direct init and we should accept this.


================
Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp:292
+  E e;
+  e = {0}; // expected-error {{cannot initialize a value of type 'E' with an rvalue of type 'int'}}
+}
----------------
cor3ntin wrote:
> Should we add a test that passes here? Even if it currently doesn't crash
> 
>  enum class E {Foo};
>  E e;
>  e = {E::Foo};
> 
> 
Sure that makes sense, more coverage is good.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153375/new/

https://reviews.llvm.org/D153375



More information about the cfe-commits mailing list