* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
2005-08-26 7:56 [Bug other/23572] New: No warning for assigning a value to a 'float' variable that overflows with option -Wextra qiyaoltc at cn dot ibm dot com
@ 2005-08-26 12:53 ` pinskia at gcc dot gnu dot org
2005-08-29 3:10 ` qiyaoltc at cn dot ibm dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-26 12:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-26 12:51 -------
Can you show an example?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
2005-08-26 7:56 [Bug other/23572] New: No warning for assigning a value to a 'float' variable that overflows with option -Wextra qiyaoltc at cn dot ibm dot com
2005-08-26 12:53 ` [Bug other/23572] " pinskia at gcc dot gnu dot org
@ 2005-08-29 3:10 ` qiyaoltc at cn dot ibm dot com
2005-08-29 3:35 ` pinskia at gcc dot gnu dot org
2005-08-29 5:18 ` qiyaoltc at cn dot ibm dot com
3 siblings, 0 replies; 16+ messages in thread
From: qiyaoltc at cn dot ibm dot com @ 2005-08-29 3:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From qiyaoltc at cn dot ibm dot com 2005-08-29 02:57 -------
OK.
GCC version: 3.4.3 20050227 (Red Hat 3.4.3-22.1)
GNU C Library: stable release version 2.3.4
OS : Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
I write a small example named overflow-test.c, here is the source code:
1 #include<stdio.h>
2 int main()
3 {
4 /* overflow. */
5 float f1 = 3.5E+38;
6 /* underflow. */
7 float f2 = 3.3E-46;
8 /* overflow. */
9 double d1 = 1.9E+308;
10 /* underflow. */
11 double d2 = 1.4E-325;
12 /* overflow, 2**32. */
13 int i = 4294967296;
14
15 printf("%e,%e,%e,%e\n",f1,f2,d1,d2);
16 printf("%d\n",i);
17 return 0;
18 }
And I compile it like this:
[qiyao@patch]$ gcc -o overflow-test -Wextra -Wall -g overflow-test.c
overflow-test.c: In function `main':
overflow-test.c:13: warning: integer constant is too large for "long" type
overflow-test.c:13: warning: overflow in implicit constant conversion
I run it,
[qiyao@patch]$ ./overflow-test
inf,0.000000e+00,inf,0.000000e+00
0
I hope this example would be helpful. Any comments are highly aprreciated!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
2005-08-26 7:56 [Bug other/23572] New: No warning for assigning a value to a 'float' variable that overflows with option -Wextra qiyaoltc at cn dot ibm dot com
2005-08-26 12:53 ` [Bug other/23572] " pinskia at gcc dot gnu dot org
2005-08-29 3:10 ` qiyaoltc at cn dot ibm dot com
@ 2005-08-29 3:35 ` pinskia at gcc dot gnu dot org
2005-08-29 5:18 ` qiyaoltc at cn dot ibm dot com
3 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-29 3:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-29 03:10 -------
I think there are some real interesting issues here.
First with -pedantic we get a warning for line 9 but nothing more. If we add f to the end of the
constant on line 5, we then get a warning.
And yes your example was useful.
The interesting thing is that we don't get a warning for the following code:
double d1 = 1.9E+308 + 1.;
which should warn.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |diagnostic
Known to work| |2.95.3 3.2.3 3.4.0 4.0.0
| |4.1.0
Last reconfirmed|0000-00-00 00:00:00 |2005-08-29 03:10:00
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
2005-08-26 7:56 [Bug other/23572] New: No warning for assigning a value to a 'float' variable that overflows with option -Wextra qiyaoltc at cn dot ibm dot com
` (2 preceding siblings ...)
2005-08-29 3:35 ` pinskia at gcc dot gnu dot org
@ 2005-08-29 5:18 ` qiyaoltc at cn dot ibm dot com
3 siblings, 0 replies; 16+ messages in thread
From: qiyaoltc at cn dot ibm dot com @ 2005-08-29 5:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From qiyaoltc at cn dot ibm dot com 2005-08-29 05:00 -------
I add suffix f to the end of float constants at line 5 and line 7, and add
option -pedantic, the output from gcc is like this:
overflow-test.c:5: warning: floating constant exceeds range of "float"
overflow-test.c:9: warning: floating constant exceeds range of "double"
overflow-test.c:13: warning: integer constant is too large for "long" type
overflow-test.c:13: warning: overflow in implicit constant conversion
It seems that gcc has checked initialization which caused overflow, but do not
check underflow, that is to say:
1 GCC does not check underflow event, at least options -pedantic does not enable
underflow check.
2 If there is some mechanism in GCC internal to check underflow and overflow,
there is a bug in gcc info about the description of -Wextra option.
Could you tell me what I could do to this problem? Maybe, it is impossible for
me to fix it, but I just want to do something more. Please give me some
suggestions and I will try to do it.
Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
@ 2006-11-25 15:24 ` manu at gcc dot gnu dot org
2007-01-09 15:09 ` manu at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-11-25 15:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2006-11-25 15:24 -------
Why this is marked as "other" ? This is either a problem on the C/C++
front-ends or it is a problem in the middle-end that doesn't handle the
overflow/underflow correctly during conversion, isn't it?
Also, this happens also for i686-pc-gnu-linux and I guess for almost any
possible host/target, so perhaps Host and Target should say something
different.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Known to fail|2.95.3 3.2.3 3.4.0 4.0.0 |2.95.3 3.2.3 3.4.0 4.0.0
|4.1.0 |4.1.0 4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
2006-11-25 15:24 ` manu at gcc dot gnu dot org
@ 2007-01-09 15:09 ` manu at gcc dot gnu dot org
2007-01-21 16:01 ` patchapp at dberlin dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-09 15:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2007-01-09 15:09 -------
(In reply to comment #0)
>
> Is this a bug either in GCC or a bug in documentation?
>
It is a bug in the documentation. As today in GCC 4.3 there is not a single
Wextra warning that has anything to do with floating-point events.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
2006-11-25 15:24 ` manu at gcc dot gnu dot org
2007-01-09 15:09 ` manu at gcc dot gnu dot org
@ 2007-01-21 16:01 ` patchapp at dberlin dot org
2007-01-22 17:05 ` manu at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: patchapp at dberlin dot org @ 2007-01-21 16:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from patchapp at dberlin dot org 2007-01-21 16:01 -------
Subject: Bug number PR 23572
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01730.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-01-21 16:01 ` patchapp at dberlin dot org
@ 2007-01-22 17:05 ` manu at gcc dot gnu dot org
2007-03-14 18:15 ` patchapp at dberlin dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-22 17:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from manu at gcc dot gnu dot org 2007-01-22 17:05 -------
*** Bug 20764 has been marked as a duplicate of this bug. ***
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dcb314 at hotmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-01-22 17:05 ` manu at gcc dot gnu dot org
@ 2007-03-14 18:15 ` patchapp at dberlin dot org
2007-03-21 21:05 ` patchapp at dberlin dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-14 18:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from patchapp at dberlin dot org 2007-03-14 18:15 -------
Subject: Bug number PR 23572
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00943.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-03-14 18:15 ` patchapp at dberlin dot org
@ 2007-03-21 21:05 ` patchapp at dberlin dot org
2007-03-22 23:04 ` manu at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-21 21:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from patchapp at dberlin dot org 2007-03-21 21:05 -------
Subject: Bug number PR 23572
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01437.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2007-03-21 21:05 ` patchapp at dberlin dot org
@ 2007-03-22 23:04 ` manu at gcc dot gnu dot org
2007-03-22 23:12 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-22 23:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from manu at gcc dot gnu dot org 2007-03-22 23:04 -------
Subject: Bug 23572
Author: manu
Date: Thu Mar 22 23:04:24 2007
New Revision: 123137
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123137
Log:
2007-03-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR other/23572
* c-lex.c (interpret_float): On overflow, emit pedantic warning if
infinities not supported, otherwise emit warning if -Woverflow. On
underflow, emit warning if -Woverflow.
* real.c (real_from_string): Return -1 if underflow, +1 if overflow
and 0 otherwise.
* real.h (real_from_string): Update declaration
testsuite/
* gcc.dg/float-range-4.c: New.
* gcc.dg/float-range-1.c: Update. Test for a warning.
* gcc.dg/float-range-3.c: New.
* gcc.dg/float-range-5.c: New.
Added:
trunk/gcc/testsuite/gcc.dg/float-range-3.c
trunk/gcc/testsuite/gcc.dg/float-range-4.c
trunk/gcc/testsuite/gcc.dg/float-range-5.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-lex.c
trunk/gcc/real.c
trunk/gcc/real.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/float-range-1.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2007-03-22 23:04 ` manu at gcc dot gnu dot org
@ 2007-03-22 23:12 ` manu at gcc dot gnu dot org
2007-04-05 23:58 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-22 23:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from manu at gcc dot gnu dot org 2007-03-22 23:12 -------
Fixed for GCC 4.3
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2007-03-22 23:12 ` manu at gcc dot gnu dot org
@ 2007-04-05 23:58 ` pinskia at gcc dot gnu dot org
2007-04-06 11:25 ` manu at gcc dot gnu dot org
2007-04-06 18:58 ` danglin at gcc dot gnu dot org
10 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-05 23:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from pinskia at gcc dot gnu dot org 2007-04-06 00:58 -------
These testcases fail on spu-elf:
+FAIL: gcc.dg/float-range-1.c (test for warnings, line 11)
+FAIL: gcc.dg/float-range-1.c (test for excess errors)
+FAIL: gcc.dg/float-range-3.c (test for excess errors)
+FAIL: gcc.dg/float-range-4.c (test for excess errors)
+FAIL: gcc.dg/float-range-5.c (test for warnings, line 9)
+FAIL: gcc.dg/float-range-5.c (test for warnings, line 10)
+FAIL: gcc.dg/float-range-5.c (test for excess errors)
FAIL: gcc.dg/float-range-1.c (test for excess errors) Excess errors:
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/float-range-1.c:11: error:
floating constant exceeds range of 'float'
Excess errors:
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/float-range-3.c:10: error:
'FP_INFINITE' undeclared (first use in this function)
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/float-range-3.c:10: error:
(Each undeclared identifier is reported only once
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/float-range-3.c:10: error: for
each function it appears in.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2007-04-05 23:58 ` pinskia at gcc dot gnu dot org
@ 2007-04-06 11:25 ` manu at gcc dot gnu dot org
2007-04-06 18:58 ` danglin at gcc dot gnu dot org
10 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-04-06 11:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from manu at gcc dot gnu dot org 2007-04-06 12:25 -------
> /home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/float-range-3.c:10: error:
> 'FP_INFINITE' undeclared (first use in this function)
Is FP_INFINITE undeclared in spu-elf?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug other/23572] No warning for assigning a value to a 'float' variable that overflows with option -Wextra
[not found] <bug-23572-11241@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2007-04-06 11:25 ` manu at gcc dot gnu dot org
@ 2007-04-06 18:58 ` danglin at gcc dot gnu dot org
10 siblings, 0 replies; 16+ messages in thread
From: danglin at gcc dot gnu dot org @ 2007-04-06 18:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from danglin at gcc dot gnu dot org 2007-04-06 19:58 -------
The same errors occur on hppa*-*-hpux*. FP_INFINITE isn't defined in
HP-UX 10. For HP-UX 11, we need "-D_HPUX_SOURCE" to get math.h to define
FP_INFINITE.
--
danglin at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |danglin at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23572
^ permalink raw reply [flat|nested] 16+ messages in thread