This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix C++ -Wno-div-by-zero
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Dirk Mueller <dmueller at suse dot de>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 06 Feb 2006 17:54:31 -0800
- Subject: Re: [PATCH] Fix C++ -Wno-div-by-zero
- References: <200601310941.18142.dmueller@suse.de> <Pine.LNX.4.64.0601311346130.29169@digraph.polyomino.org.uk> <200602061529.56382.dmueller@suse.de>
Dirk Mueller wrote:
>>There's a difference here from the C behavior: the C front end doesn't
>>warn for division by a floating point zero constant (although it warns for
>>division of a floating point value by an integer zero) since explicit
>>division by 0.0 is used as a way of generating Inf and NaN. (Not a
>>problem with this patch, since it's a pre-existing condition.)
>
> Yes, should we consolidate that?
Yes, that would be an improvement. I have no strong opinion about
whether or not a warning is appropriate in that case, but I think it
would be better for the C and C++ front ends to match.
> 2006-02-02 Dirk Mueller <dmueller@suse.com>
>
> * c.opt: C++ frontend supports -Wdiv-by-zero.
> * c-opts.c (c_common_handle_option): Remove dead case.
>
> * typeck.c (build_binary_op): Annotate div-by-zero
> warnings to make -Wno-div-by-zero have an effect.
>
> g++.dg/warn/Wdiv-by-zero.C: New test.
> g++.dg/warn/Wno-div-by-zero.C: New.
OK, thanks.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713