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: unassig...@gcc.gnu.org ReportedBy: vbyakov...@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);