User account creation filtered due to spam.
int c = INT_MAX + 1;
should yield only warnings, not an error, with -pedantic-errors.
Not a regression.
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:
c = INT_MAX + 1;
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?
--- 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. */
- 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
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
Subject: Bug 19977
Date: Tue Jan 2 20:07:44 2007
New Revision: 120355
2007-01-02 Manuel Lopez-Ibanez <firstname.lastname@example.org>
* c-typeck.c (store_init_value): Don't emit pedantic overflow
warning for non-static initializers.
* gcc/testsuite/gcc.dg/overflow-warn-3.c: Remove XFAIL.
* gcc/testsuite/gcc.dg/overflow-warn-4.c: Remove XFAIL.
Fixed in mainline.