Re: False positive from -Warray-bounds?

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

 



On 2011-12-29 15:24:08 -0800, Ian Lance Taylor wrote:
> I guess it's a matter of perspective.  What that text is intended to say
> is: the compiler can prove that the array access is out of bounds.

... based on an incorrect hypothesis (that the path can be reached).
With an incorrect hypothesis, one can prove anything. So, I don't
think that would be a valid proof.

For instance, compiling the following code with -O2 -Warray-bounds -c
triggers the warning.

unsigned int f(unsigned int value)
{
  unsigned int i = (value & 0xffff);
  return (i == 0xffff ? 0xffffffff : i);
}

static int arr1[10];

void t(unsigned int s)
{
  if (s >> 1 == 0)
    {
      arr1[f(s)] = 0;
      arr1[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