[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread jlame646 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #9 from Jason Liam --- (In reply to Andrew Pinski from comment #8) Does that imply that following program is also invalid? GCC rejects the below program but msvc accepts. ``` struct A { explicit A(int = 10); A()= default; }; A

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #8 from Andrew Pinski --- (In reply to Jason Liam from comment #7) > (In reply to Andrew Pinski from comment #5) > > std::vector 's constructor which takes std::size_t is marked as explicit. > > But you're missing that the

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread jlame646 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #7 from Jason Liam --- (In reply to Andrew Pinski from comment #5) > std::vector 's constructor which takes std::size_t is marked as explicit. But you're missing that the initializer list ctor is preferred/choosen over the size_t

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #6 from Andrew Pinski --- I know cppreference is not the standard but it is a decent reference to start with. https://en.cppreference.com/w/cpp/container/vector/vector Without the explicit, clang will also reject it as being

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #5 from Andrew Pinski --- (In reply to Jason Liam from comment #4) > But which constructor is explicit here? I don't see any explicit ctor here. std::vector 's constructor which takes std::size_t is marked as explicit.

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread jlame646 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #4 from Jason Liam --- But which constructor is explicit here? I don't see any explicit ctor here.

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 Andrew Pinski changed: What|Removed |Added Resolution|--- |DUPLICATE

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #2 from Andrew Pinski --- (In reply to Andrew Pinski from comment #1) > Reduced to: > ``` > struct B > { > B(double); > }; > > struct C > { > C(int); > }; > > > void func(B); > void func(C); > > int main() { > func({ 4.2

[Bug c++/113884] GCC rejects valid program saying ambiguous call when using std::vector

2024-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884 --- Comment #1 from Andrew Pinski --- Reduced to: ``` struct B { B(double); }; struct C { C(int); }; void func(B); void func(C); int main() { func({ 4.2 }); } ```