This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21438] Warning about division by zero depends on lexical form
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 May 2005 18:18:43 -0000
- Subject: [Bug c/21438] Warning about division by zero depends on lexical form
- References: <20050507080910.21438.neil@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-07 18:18 -------
Confirmed, it is obvious from looking at the code what was wrong. The following patch should fix it
but I don't have time to test it fully:
Index: c-typeck.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.439
diff -u -p -r1.439 c-typeck.c
--- c-typeck.c 2 May 2005 16:02:19 -0000 1.439
+++ c-typeck.c 7 May 2005 18:17:53 -0000
@@ -7462,7 +7462,8 @@ build_binary_op (enum tree_code code, tr
case EXACT_DIV_EXPR:
/* Floating point division by zero is a legitimate way to obtain
infinities and NaNs. */
- if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1))
+ if (warn_div_by_zero && skip_evaluation == 0
+ && integer_zerop (op1) && code0 != REAL_TYPE)
warning (0, "division by zero");
if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2005-05-07 18:18:42
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21438