public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110689] New: problem of initializer list
@ 2023-07-16 15:32 irip at qq dot com
2023-07-16 16:35 ` [Bug c++/110689] " pinskia at gcc dot gnu.org
2023-07-17 9:24 ` [Bug c++/110689] problem of initializer list and conversion operators redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: irip at qq dot com @ 2023-07-16 15:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110689
Bug ID: 110689
Summary: problem of initializer list
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: irip at qq dot com
Target Milestone: ---
In the code, declare a struct/class and define multiple types of list
initializers, then use list initializers, such as:
struct M {
operator char() { return 'a'; }
} m;
struct S {
S(std::initializer_list<int>) { flag = 1; }
S(std::initializer_list<float>) { flag = 2; }
};
……
S s = { m };
Compiler error:
conversion from '<brace-enclosed initializer list>' to 'S' is ambiguous
This is allowed in the C++ standard and requires overloaded parsing when the
list is initialized.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110689] problem of initializer list
2023-07-16 15:32 [Bug c++/110689] New: problem of initializer list irip at qq dot com
@ 2023-07-16 16:35 ` pinskia at gcc dot gnu.org
2023-07-17 9:24 ` [Bug c++/110689] problem of initializer list and conversion operators redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-16 16:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110689
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Testcase that is complete:
```
#include <initializer_list>
struct M {
operator char() { return 'a'; }
} m;
int flag;
struct S {
S(std::initializer_list<int>) { flag = 1; }
S(std::initializer_list<float>) { flag = 2; }
};
S s = { m };
```
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110689] problem of initializer list and conversion operators
2023-07-16 15:32 [Bug c++/110689] New: problem of initializer list irip at qq dot com
2023-07-16 16:35 ` [Bug c++/110689] " pinskia at gcc dot gnu.org
@ 2023-07-17 9:24 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-17 9:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110689
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-07-17
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-17 9:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-16 15:32 [Bug c++/110689] New: problem of initializer list irip at qq dot com
2023-07-16 16:35 ` [Bug c++/110689] " pinskia at gcc dot gnu.org
2023-07-17 9:24 ` [Bug c++/110689] problem of initializer list and conversion operators redi at gcc dot gnu.org
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).