https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71985
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Markus Trippelsdorf from comment #3)
> As a matter of consistency, I really think there shouldn't be
> different cases where we error out or warn. So treating the new C++11
> uniform initialization case the same as the older ones makes sense to me.
>
> Of course, Jason as the C++ maintainer has the last word.
> CCing him.
The rationale is explained here:
https://gcc.gnu.org/wiki/FAQ#Wnarrowing
In a nutshell, error when it is sure that there is a change of value or loss of
precision, and warn otherwise.
In the example here, for any value of d in 1, 2, 1.0, 2.0, there is no loss of
precision or change of value. Even for:
double d = 0.5;
std::vector<int> v1 { d };
g++ cannot know at the time of warning that d == 0.5, it just sees a variable
'd' that may have any value, such as 0.0.