This is the mail archive of the gcc-patches@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]

PR 21438 : Warning about division by zero depends on lexical form


:ADDPATCH c:

The following patch was proposed by Andrew Pinski but never properly submitted.

The C front-end does not warning about division by zero for floating
point because it is a legitimate way of obtaining infinities and NaNs.
With this patch we don't emit the warning if the integer zero is
promoted to real type.

Bootstrapped and regression tested with --enable-languages=all for
revision 120588 on i686-pc-gnu-linux.


The C++ front-end, on the contrary, warns always. Is this an inconsistency?


2007-01-14  Andrew Pinski  <pinskia@gmail.com>
                   Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

 PR c/21438
 * gcc/c-typeck.c (build_binary_op): Don't give division by zero
warning if integer zero is promoted to REAL_TYPE.

testsuite:
2007-01-14  Andrew Pinski  <pinskia@gmail.com>
                   Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

 PR c/21438
 * gcc.dg/Wdiv-by-zero.c: New.

Attachment: wdivbyzero.diff
Description: Text document


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