public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110958] New: [CWG 2137][accepts-invalid] Copy-list-initialization with single element of same class only considers converting constructors as viable
@ 2023-08-09 10:44 davveston at gmail dot com
0 siblings, 0 replies; only message in thread
From: davveston at gmail dot com @ 2023-08-09 10:44 UTC (permalink / raw)
To: gcc-bugs
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).
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-09 10:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 10:44 [Bug c++/110958] New: [CWG 2137][accepts-invalid] Copy-list-initialization with single element of same class only considers converting constructors as viable davveston at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).