Re: False positive from -Warray-bounds?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Another interesting testcase:

static int a[10], b[10], c[10], d[10];

unsigned int f (unsigned int v)
{
  return v == 17 ? 11 : v;
}

unsigned int g (unsigned int v)
{
  return v == 17 ? 17 : v;
}

void t (unsigned int s)
{
  if (s >> 1 == 0)
    {
      a[f(s)] = 0;
      a[f(s)] = 0;
      b[f(s)] = 0;
      c[g(s)] = 0;
      c[g(s)] = 0;
      d[H(s)] = 0;
    }
}

$ gcc-snapshot -O2 -Warray-bounds -c bounds.c -DH=f
bounds.c: In function 't':
bounds.c:17:8: warning: array subscript is above array bounds [-Warray-bounds]
bounds.c:19:8: warning: array subscript is above array bounds [-Warray-bounds]
bounds.c:20:8: warning: array subscript is above array bounds [-Warray-bounds]

$ gcc-snapshot -O2 -Warray-bounds -c bounds.c -DH=g
bounds.c: In function 't':
bounds.c:17:8: warning: array subscript is above array bounds [-Warray-bounds]

I don't see the logic.

Note: line 17 is the first "a[f(s)] = 0;".

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux