https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110958
Bug ID: 110958 Summary: [CWG 2137][accepts-invalid] Copy-list-initialization with single element of same class only considers converting constructors as viable Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davveston at gmail dot com Target Milestone: --- There are several (closed) bug reports relating to CWG 2137, particularly highlighting the still present implementation divergence between e.g. GCC and Clang. These mostly relate to whether or not a non-aggregate class initialized via single element init-list of same-class resolves to the rules of [over.match.list] or not. See e.g. https://gcc.gnu.org/bugzilla//show_bug.cgi?id=85577 and its duplicates I interpret the wording the same way as GCC, such that after CWG 2137 initializer list constructors take precedence over e.g. copy constructors ([over.match.list]/1.1). However, when falling through to [over.match.list]/1.2, GCC seems to consider only converting constructors as if following [over.match.ctor]/1, whereas by [over.match.list]/1.2 explicit constructors are still viable, although leading to an ill-formed program if picked as most viable. The following example is accepted by GCC: struct S { S() = default; S(S const&) = default; // #1 explicit S(S&) = delete; // #2 }; S a; S b = {a}; // #3 As #3 picks #1 for the copy-list-initialization. As of CWG 2137 I believe it should be rejected as ill-formed as #2 should be selected instead: ill-formed not due to deleted definition but due to the last paragraph of [over.match.list]/1. (Holds for various GCC versions and C++ language versions).