public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55079] New: [4.8 regeression] false positive -Warray-bounds
@ 2012-10-26  9:56 dimhen at gmail dot com
  2012-10-26 10:09 ` [Bug tree-optimization/55079] " rguenth at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: dimhen at gmail dot com @ 2012-10-26  9:56 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55079
           Summary: [4.8 regeression] false positive -Warray-bounds
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dimhen@gmail.com


$ cat tst.c
int f(unsigned len, int buflen)
{
    unsigned taillen;
    unsigned slen;
    unsigned i;
    int b[17];            /* needed <= 17 to trigger Warning */
    int j = 0;            /* needed to trigger Warning */

    b[0] = 0;
    taillen= buflen & 7;    /* taillen [0..7] */

    if(taillen) {        /* taillen [1..7] */
    slen= 8 - taillen;    /* slen    [7..1] */
    if (len<slen)        /* needed to trigger Warning  */
        slen=len;        /* slen' < slen  */
    for(i=0; i<slen; i++) {
      j = b[taillen];    /* taillen + slen = [1..7] + [7..1] = 8 */
      taillen++;
    }
    }
    return j;
}
$ gcc -Warray-bounds -c -O3 tst.c
tst.c: In function 'f':
tst.c:17:9: warning: array subscript is above array bounds [-Warray-bounds]
    j = b[taillen]; /* taillen + slen = [1..7] + [7..1] = 8 */
         ^
gcc version 4.8.0 20121026 (experimental) [trunk revision 192837] (GCC)

- if i remove some code then warning disappeared
- why '18' is safe array top-bound?


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

end of thread, other threads:[~2012-12-12  9:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26  9:56 [Bug tree-optimization/55079] New: [4.8 regeression] false positive -Warray-bounds dimhen at gmail dot com
2012-10-26 10:09 ` [Bug tree-optimization/55079] " rguenth at gcc dot gnu.org
2012-10-30  9:34 ` [Bug tree-optimization/55079] [4.8 regression] " rguenth at gcc dot gnu.org
2012-10-30  9:35 ` rguenth at gcc dot gnu.org
2012-11-02 16:35 ` hubicka at gcc dot gnu.org
2012-11-02 16:47 ` hubicka at gcc dot gnu.org
2012-11-02 18:45 ` hubicka at gcc dot gnu.org
2012-11-02 20:51 ` hubicka at gcc dot gnu.org
2012-11-14 19:31 ` [Bug tree-optimization/55079] [4.8 regression] false positive -Warray-bounds (also seen at -O3 bootstrap) hubicka at gcc dot gnu.org
2012-11-15  1:01 ` hubicka at gcc dot gnu.org
2012-12-07 12:55 ` rguenth at gcc dot gnu.org
2012-12-10 13:23 ` rguenth at gcc dot gnu.org
2012-12-10 13:50 ` rguenth at gcc dot gnu.org
2012-12-10 14:14 ` rguenth at gcc dot gnu.org
2012-12-10 16:27 ` hubicka at ucw dot cz
2012-12-11 10:06 ` rguenth at gcc dot gnu.org
2012-12-11 10:08 ` rguenth at gcc dot gnu.org
2012-12-12  9:33 ` schwab 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).