Closed ranaanoop closed 3 months ago
The change was made by P0960R3. Presumably copy-initialization should be left unchanged.
Suggested resolution:
Change [dcl.init.general] p16.5 as indicated:
Otherwise, if the destination type is an array and the initialization is direct-initialization, the object is initialized as follows. [...]
Add a new bullet after [dcl.init.general] p16.5
Otherwise, if the destination type is an array and the initialization is copy-initialization, the program is ill-formed.
The change was made by P0960R3.
I see, before posting this issue I was trying to find the reason(thing that caused this change) why this was changed in the diff section of the draft but could not find it there. Now I see that it was [P0960R3] that introduced the change.
Thanks @frederick-vs-ja , I've incorporated your suggestion in the issue's "suggested resolution" part at the end of this issue.
CWG2824
Full name of submitter: Anoop Rana
Reference (section label): [dcl.init.general]
Link to reflector thread (if any):
Issue description: The statement
std::string arr[] = "some string";
seems to be allowed by the dcl.init.general#16.5. We observe implementation divergence here.In C++ 17 this was not allowed as per dcl.init#17.5 which used to say "Otherwise, if the destination type is an array, the program is ill-formed. " but in C++20 this was changed to dcl.init.general#16.5 to say:
Suggested resolution:
This should be made ill-formed again. Change dcl.init.general#16.5 as indicated:
Also add a separate bullet point after dcl.init.general#16.5 saying: