From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9EFE83858D33; Wed, 9 Aug 2023 10:44:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EFE83858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691577879; bh=3yw0juL2wanhRWZL5blbwqTKir3wfGO5lNRvpbA7BiA=; h=From:To:Subject:Date:From; b=rS/QIWArxeNR3haZ9s578juG22e8o0PR51HjphSqwaR0/pz8xxiIIgQ7+Zfsf43cL lliC6idTZn3zoXep06ewQvF3soehB9W22SbEsMkZyCmKX1HM9eLLg0WAINLM4xfJA2 zTTPJ6jlCgS/eK+Pa5UmO07I6o7oFvBToyt4H8LQ= From: "davveston at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110958] New: [CWG 2137][accepts-invalid] Copy-list-initialization with single element of same class only considers converting constructors as viable Date: Wed, 09 Aug 2023 10:44:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: davveston at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110958 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 a= nd Clang. These mostly relate to whether or not a non-aggregate class initiali= zed 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=3D85577 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 consid= er only converting constructors as if following [over.match.ctor]/1, whereas by [over.match.list]/1.2 explicit constructors are still viable, although lead= ing to an ill-formed program if picked as most viable.=20 The following example is accepted by GCC: struct S { S() =3D default; S(S const&) =3D default; // #1 explicit S(S&) =3D delete; // #2 }; S a;=20 S b =3D {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-form= ed 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).=