This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/middle-end/diagnostic] Do not warn about unused out of bounds array refs


On Tue, Mar 20, 2007 at 05:32:59PM +0100, Dirk Mueller wrote:
> On Tuesday, 20. March 2007, Richard Guenther wrote:
> 
> > I still would prefer you'd warn at dereference or escape sites only
> > (escape sites
> > are possible dereference sites).
> 
> That would disable warnings about taking addresses of array references that 
> are out of bounds. Right?

If you never dereference such a pointer and it doesn't escape.

char a[10];
char *r;

int foo (void)
{
  char *p = &a[12];	// This wouldn't warn
  char *q = &a[12];
  *q = 5;		// We would warn here
  r = &a[-1];		// and here as well
  bar ();
}

But if you never dereference it and it doesn't escape, then it is completely
harmless.
As is -Warray-bounds just causes too many false positives, see
PR31227 or e.g. yesterday when I tried to bootstrap with obj-c++
among --enable-languages trunk didn't bootstrap because of it either.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]