[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [PATCH] Fix PR/8268: implement compile time array subscript checking
From:       Dirk =?iso-8859-1?q?M=FCller?= <dmueller () suse ! de>
Date:       2006-12-07 9:51:47
Message-ID: 200612071051.49425.dmueller () suse ! de
[Download RAW message or body]

Am Donnerstag, 7. Dezember 2006 00:35 schrieb Andrew Pinski:

> Your documentation for the warning is incorrect as
> you say:

You're right, I forgot to update the documentation. 

> But that is wrong as it is actived only with -O1 -ftree-vrp or -O2 and
> higher with VRP still turned on.


+@item -Warray-bounds
+@opindex Warray-bounds
+This option is only active when @option{-O2} or higher is active. It warns
+about subscripts to arrays that are always out of bounds.
+

Ok? Or should I mention the -ftree-vrp dependency explicitely ?

I can also make the warning work without -O2 for constant subscripts, so the 
documentation doesn't have to be that precise. Updating the patch for that is 
easy, but the regtest will take another day or two. 

> Second I would not just set it for the C family of languages:

Which language do you have in mind? I'm not very familiar with non-C-style 
languages, but afaik in Java out of bound accesses are legal (throw an 
exception) and fortran already has a warning to handle this (just guessed 
this from some patches I saw on this mailing list). Ada seems to ignore -Wall 
completely. 


> As far as I know VRP current does not get the above correctly,
> that is change n to a nonconstant and uncomment the bounds checking
> code.

VRP seems to try to be correct as far as "the actual range is within the range 
that is determined". So in your testcase it determines a range of [+1,+INF], 
which is okay, just not precise. 

This is particularly the reason why I only warn if the access is 
non-overlapping with the vrp determined range. E.g. if you change the i = 1; 
in your testcase to i = 10; it will warn, otherwise it will not. This is 
because I like to use -Werror=array-bounds and therefore do not like false 
positives. 


Dirk
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic