-Warray-bounds issue

Matt Hargett matt@use.net
Mon Jul 23 18:45:00 GMT 2007


Hi,

I'll be teaching a class this week on code analysis and I wanted to 
demonstrate GCC 4.3's new array bounds analysis capabilities.
Unfortunately, I can't seem to get the new array bounds warnings to appear in 
gcc-4.3-20070720 using the commandline of '-O2 -Warray-bounds' with either of 
the following code:

#include <stdlib.h>

int main(int argc, char **argv)
{
        size_t size = 16;
        char p[size];
        p[16] = 0;
}


--

#include <stdlib.h>

int main(int argc, char **argv)
{
        char p[16];
        p[16] = 0;
}

--

I have tried making the overflow more pronounced, using -O3, and various other 
things. I bootstrapped from the sources, but there didn't appear to be any 
special configure switch I was supposed to apply. I did a profiledbootstrap.

If someone could help me figure out what I'm doing wrong, or if I should use 
an older snapshot, that would be great. I am really excited about the 
increased quality this has the capability to bring to all open source 
applications!

Thanks in advance for any help!



More information about the Gcc mailing list