public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
@ 2006-12-09 14:28 ` manu at gcc dot gnu dot org
2006-12-10 17:18 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-12-09 14:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from manu at gcc dot gnu dot org 2006-12-09 14:28 -------
I believe that the culprit is a call to constant_expression_warning at
c-typeck.c (store_init_value). The comment just above this call says "ANSI
wants warnings about out-of-range constant initializers". However, if the
out-of-range constant initialiser is the result of an operation, a warning has
been emitted already by overflow_warning. If the out-of-range is the result of
a value that overflowed when converted to the type of the variable, a warning
should have been emitted by convert_and_check.
So my question is, are we required to emit a special (pedantic) warning for:
int c= INT_MAX + 1;
different from the warning we already give for:
int c;
c = INT_MAX + 1;
?
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Last reconfirmed|2005-12-18 01:39:36 |2006-12-09 14:28:13
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
2006-12-09 14:28 ` [Bug c/19977] overflow in non-static initializer should not be pedwarn manu at gcc dot gnu dot org
@ 2006-12-10 17:18 ` manu at gcc dot gnu dot org
2006-12-15 1:15 ` patchapp at dberlin dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-12-10 17:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2006-12-10 17:17 -------
This patch seems to fix this. I get:
XPASS: gcc.dg/overflow-warn-3.c constant (test for bogus messages, line 42)
XPASS: gcc.dg/overflow-warn-4.c constant (test for bogus messages, line 42)
and no new failures on the overflow testcases.
I still have to properly bootstrap and regression test it. Any thoughts?
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c (revision 119686)
+++ gcc/c-typeck.c (working copy)
@@ -4358,7 +4360,7 @@ store_init_value (tree decl, tree init)
/* ANSI wants warnings about out-of-range constant initializers. */
STRIP_TYPE_NOPS (value);
- constant_expression_warning (value);
+ if (TREE_STATIC (decl)) constant_expression_warning (value);
/* Check if we need to set array size from compound literal size. */
if (TREE_CODE (type) == ARRAY_TYPE
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
2006-12-09 14:28 ` [Bug c/19977] overflow in non-static initializer should not be pedwarn manu at gcc dot gnu dot org
2006-12-10 17:18 ` manu at gcc dot gnu dot org
@ 2006-12-15 1:15 ` patchapp at dberlin dot org
2007-01-02 20:08 ` manu at gcc dot gnu dot org
2007-01-06 9:37 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: patchapp at dberlin dot org @ 2006-12-15 1:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from patchapp at dberlin dot org 2006-12-15 01:15 -------
Subject: Bug number PR c/19977
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/2006-12/msg01068.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-12-15 1:15 ` patchapp at dberlin dot org
@ 2007-01-02 20:08 ` manu at gcc dot gnu dot org
2007-01-06 9:37 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-02 20:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2007-01-02 20:07 -------
Subject: Bug 19977
Author: manu
Date: Tue Jan 2 20:07:44 2007
New Revision: 120355
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120355
Log:
2007-01-02 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/19977
* c-typeck.c (store_init_value): Don't emit pedantic overflow
warning for non-static initializers.
testsuite/
* gcc/testsuite/gcc.dg/overflow-warn-3.c: Remove XFAIL.
* gcc/testsuite/gcc.dg/overflow-warn-4.c: Remove XFAIL.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/overflow-warn-3.c
trunk/gcc/testsuite/gcc.dg/overflow-warn-4.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-01-02 20:08 ` manu at gcc dot gnu dot org
@ 2007-01-06 9:37 ` manu at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-06 9:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2007-01-06 09:36 -------
Fixed in mainline.
--
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=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19977] overflow in non-static initializer should not be pedwarn
2005-02-15 22:31 [Bug c/19977] New: " jsm28 at gcc dot gnu dot org
@ 2005-02-16 3:29 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-16 3:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-15 21:20 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Known to fail| |3.3.3 3.2.3 3.4.0 4.0.0
| |3.0.4 2.95.3
Last reconfirmed|0000-00-00 00:00:00 |2005-02-15 21:20:00
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19977
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-01-06 9:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-19977-230@http.gcc.gnu.org/bugzilla/>
2006-12-09 14:28 ` [Bug c/19977] overflow in non-static initializer should not be pedwarn manu at gcc dot gnu dot org
2006-12-10 17:18 ` manu at gcc dot gnu dot org
2006-12-15 1:15 ` patchapp at dberlin dot org
2007-01-02 20:08 ` manu at gcc dot gnu dot org
2007-01-06 9:37 ` manu at gcc dot gnu dot org
2005-02-15 22:31 [Bug c/19977] New: " jsm28 at gcc dot gnu dot org
2005-02-16 3:29 ` [Bug c/19977] " pinskia at gcc dot gnu dot 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).