This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52632] New: GCC compfail on O0
- From: "vbyakovl23 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Mar 2012 09:01:09 +0000
- Subject: [Bug c/52632] New: GCC compfail on O0
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52632
Bug #: 52632
Summary: GCC compfail on O0
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vbyakovl23@gmail.com
Test case a.c gives following compfail when compiling with O0
gcc âO0 âc a.c
a.c: In function 'foo':
a.c:4:1: error: size of unnamed array is negative
For higher opt level it's ok.
gcc version 4.8.0 20120319 (experimental) (GCC)
The failure happened because FE on âO0 replaces builtin call by zero if it is
not folded. See gcc/builtins.c, fold_builtin_1(), line 10270
switch (fcode)
{
case BUILT_IN_CONSTANT_P:
{
tree val = fold_builtin_constant_p (arg0);
/* Gimplification will pull the CALL_EXPR for the builtin out of
an if condition. When not optimizing, we'll not CSE it back.
To avoid link error types of regressions, return false now. */
if (!val && !optimize)
val = integer_zero_node;
return val;
}
It may be fixed by a patch that disabled error message in case of not optimize.
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 160d393..1ba3f51 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5345,7 +5345,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (TREE_CODE (size) == INTEGER_CST && size_maybe_const)
{
constant_expression_warning (size);
- if (tree_int_cst_sgn (size) < 0)
+ if ((pedantic || optimize) && tree_int_cst_sgn (size) < 0)
{
if (name)
error_at (loc, "size of array %qE is negative",
name);