[Bug c++/71446] Incorrect overload resolution when using designated initializers

roman.perepelitsa at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Feb 25 15:06:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71446

--- Comment #4 from Roman Perepelitsa <roman.perepelitsa at gmail dot com> ---
Please take a look at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71446#c1.
This code compiles. Given that it contains `{.value = 0}`, one would reasonably
expect that it creates an instance of a struct with the data member `value` set
to zero. However, it doesn't. The literal `{.value = 0}` creates an instance of
type `std::initialize_list<int>`. This is very misleading. The code should
either not compile or do what was intended (which is also what C++20 requires
and what clang does).


More information about the Gcc-bugs mailing list