This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/21438] Warning about division by zero depends on lexical form


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]