public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21438] New: Warning about division by zero depends on lexical form
@ 2005-05-07 8:09 neil at gcc dot gnu dot org
2005-05-07 18:18 ` [Bug c/21438] " pinskia at gcc dot gnu dot org
2005-05-07 18:20 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 8+ messages in thread
From: neil at gcc dot gnu dot org @ 2005-05-07 8:09 UTC (permalink / raw)
To: gcc-bugs
GCC is supposed to suppress division by zero warnings when floating point.
However the warning is based on the lexical form, i.e. the unpromoted type. I
suggest it should depend on the promoted type.
float f[] = {
1.0f/0.0f, // No warning
1.0f/0 // Warning (and diagnostic is on the wrong line in 3.3 at least)
};
--
Summary: Warning about division by zero depends on lexical form
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: neil at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21438
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/21438] Warning about division by zero depends on lexical form
2005-05-07 8:09 [Bug c/21438] New: Warning about division by zero depends on lexical form neil at gcc dot gnu dot org
@ 2005-05-07 18:18 ` pinskia at gcc dot gnu dot org
2005-05-07 18:20 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-07 18:18 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/21438] Warning about division by zero depends on lexical form
2005-05-07 8:09 [Bug c/21438] New: Warning about division by zero depends on lexical form neil at gcc dot gnu dot org
2005-05-07 18:18 ` [Bug c/21438] " pinskia at gcc dot gnu dot org
@ 2005-05-07 18:20 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-07 18:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-07 18:20 -------
Hmm, I wonder why C++ warns though:
t.c:2: warning: division by zero in '1.0e+0f / 0.'
t.c:3: warning: division by zero in '1.0e+0f / 0'
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.2.3 3.3.4 3.4.2 4.0.0
| |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21438
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <bug-21438-6@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-21438-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c/21438] Warning about division by zero depends on lexical form
[not found] <bug-21438-4@http.gcc.gnu.org/bugzilla/>
@ 2021-09-28 8:25 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-28 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21438
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Last reconfirmed|2005-12-18 01:45:12 |2021-9-28
Known to fail| |
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #5)
> Subject: Bug 21438
The only thing this patch did was uniformed the code between the front-ends.
I am going to look into fix this once and for all.
GCC is the only compiler which warns for this case even.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-09-28 8:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-07 8:09 [Bug c/21438] New: Warning about division by zero depends on lexical form neil at gcc dot gnu dot org
2005-05-07 18:18 ` [Bug c/21438] " pinskia at gcc dot gnu dot org
2005-05-07 18:20 ` pinskia at gcc dot gnu dot org
[not found] <bug-21438-6@http.gcc.gnu.org/bugzilla/>
2007-01-16 0:57 ` patchapp at dberlin dot org
2007-03-12 1:32 ` patchapp at dberlin dot org
2007-03-14 18:38 ` manu at gcc dot gnu dot org
2007-03-14 18:39 ` manu at gcc dot gnu dot org
[not found] <bug-21438-4@http.gcc.gnu.org/bugzilla/>
2021-09-28 8:25 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).