[Bug c++/50810] c++0x-compat does not warn about narrowing conversions
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Oct 22 01:15:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50810
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> 2011-10-22 01:15:14 UTC ---
(In reply to comment #3)
> (detail: not sure about the 'if (!warn_narrowing) return;' at the beginning of
> check_narrowing: probably we don't want -Wno-narrowing to suppress the warnings
> enabled of -Wc++0x-compat)
I think what you want is that -Wc++0x-compat enables -Wnarrowing independently
of -std=, but still -Wc++0x-compat -Wno-narrowing should disable it. See the
handling of Wlonglong in c-opts.c. So:
if (!ok)
{
if (cxx_dialect != cxx98)
pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE "
"from %qT to %qT inside { }", init, ftype, type);
else
warning_at (input_location, OPT_Wnarrowing, "narrowing conversion of
%qE "
"from %qT to %qT inside { }", init, ftype, type);
}
This approach also allows the user to specify -Wnarrowing to get the warnings
independently of -std=.
More information about the Gcc-bugs
mailing list