public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52632] New: GCC compfail on O0
@ 2012-03-20  9:05 vbyakovl23 at gmail dot com
  2012-03-20  9:11 ` [Bug c/52632] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vbyakovl23 at gmail dot com @ 2012-03-20  9:05 UTC (permalink / raw)
  To: gcc-bugs

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);


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-26  8:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-20  9:05 [Bug c/52632] New: GCC compfail on O0 vbyakovl23 at gmail dot com
2012-03-20  9:11 ` [Bug c/52632] " pinskia at gcc dot gnu.org
2012-03-20 10:29 ` vbyakovl23 at gmail dot com
2012-03-20 10:59 ` mikpe at it dot uu.se
2012-03-20 11:12 ` joseph at codesourcery dot com
2012-03-20 13:50 ` mikpe at it dot uu.se
2012-03-21  8:06 ` izamyatin at gmail dot com
2012-03-21  8:49 ` jakub at gcc dot gnu.org
2014-03-26  8:23 ` mpolacek at gcc dot gnu.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).