This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50810] c++0x-compat does not warn about narrowing conversions
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 22 Oct 2011 01:15:14 +0000
- Subject: [Bug c++/50810] c++0x-compat does not warn about narrowing conversions
- Auto-submitted: auto-generated
- References: <bug-50810-4@http.gcc.gnu.org/bugzilla/>
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=.