https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71985
Bug ID: 71985 Summary: narrowing in initializer lists is not ill-formed where required Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nico at josuttis dot de Target Milestone: --- double d; std::vector<int> v1 { d }; only gives a warning instead of an error. Unlike https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783, here IMO there is a clear requoirement to result in an error because: 5.4.1 List-initialization [dcl.init.list] says: > Otherwise, if T is a class type, constructors are considered. The applicable > constructors are enumerated > and the best one is chosen through overload resolution (13.3, 13.3.1.7). If a > narrowing conversion (see > below) is required to convert any of the arguments, the program is ill-formed. and later: > struct B { > B(std::initializer_list<int>); > }; > B b1 { 1, 2 }; // creates initializer_list<int> and calls constructor > B b2 { 1, 2.0 }; // error: narrowing This looks to me like my example, except that d is no constant. But I see no difference between constants and avriables applied here because according to 5.4.1 List-initialization [dcl.init.list]: > A narrowing conversion is an implicit conversion > — from a floating-point type to an integer type Applies to all versions since C++11. It tried 5.4.0 and other versions.