public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55222] New: weird unstable "array subscript is above array bounds" warning
@ 2012-11-06 13:20 akim.demaille at gmail dot com
  2012-12-09  3:15 ` [Bug tree-optimization/55222] [4.8 Regression] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: akim.demaille at gmail dot com @ 2012-11-06 13:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55222

             Bug #: 55222
           Summary: weird unstable "array subscript is above array bounds"
                    warning
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@gmail.com


The following piece of code is a reduced version of a parser generated by
Bison.  It triggers a new warning (which must be very recently added to 4.8, as
last week or so there were no such warning AFAICT).

One issue is that the warning looks like a certainty, "array subscript is above
array bounds", well, no it is not, and another is that if I remove the previous
line, which displays "yyi", then the warning disappears.  This is fishy (at
least to my eyes).


$ cat array.c
#include <stdio.h>

typedef unsigned char uint8;
typedef signed char int8;

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
static const uint8 yyr2[] =
{
       0,     2,     0
};

/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const uint8 yyprhs[] =
{
       0,     0,     3
};

/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
static const int8 yyrhs[] =
{
       4,     0,    -1,    -1
};

void
yy_reduce_print (int yyrule)
{
  int yyi;
  for (yyi = 0; yyi < yyr2[yyrule]; yyi++)
    {
      fprintf (stderr, "$%d = ", yyi);
      fprintf (stderr, "%d\n", yyrhs[yyprhs[yyrule] + yyi]);
    }
}
$ gcc-mp-4.8 -Wall -O3 array.c -c
array.c: In function 'yy_reduce_print':
array.c:32:37: warning: array subscript is above array bounds [-Warray-bounds]
       fprintf (stderr, "%d\n", yyrhs[yyprhs[yyrule] + yyi]);
                                     ^
$ gcc-mp-4.8 --version
gcc-mp-4.8 (MacPorts gcc48 4.8-20121028_0) 4.8.0 20121028 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc-mp-4.7 -Wall -O3 array.c -c
$ gcc-mp-4.7 --version
gcc-mp-4.7 (MacPorts gcc47 4.7.2_2) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$


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

* [Bug tree-optimization/55222] [4.8 Regression] weird unstable "array subscript is above array bounds" warning
  2012-11-06 13:20 [Bug c/55222] New: weird unstable "array subscript is above array bounds" warning akim.demaille at gmail dot com
@ 2012-12-09  3:15 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-09  3:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55222

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |RESOLVED
          Component|c                           |tree-optimization
         Resolution|                            |DUPLICATE
            Summary|weird unstable "array       |[4.8 Regression] weird
                   |subscript is above array    |unstable "array subscript
                   |bounds" warning             |is above array bounds"
                   |                            |warning

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-09 03:14:52 UTC ---
It was a bug in 4.8.0 which has since been fixed.

*** This bug has been marked as a duplicate of bug 55085 ***


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

end of thread, other threads:[~2012-12-09  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-06 13:20 [Bug c/55222] New: weird unstable "array subscript is above array bounds" warning akim.demaille at gmail dot com
2012-12-09  3:15 ` [Bug tree-optimization/55222] [4.8 Regression] " pinskia 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).