This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR/8268: implement compile time array subscript checking
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: dmuell at gmx dot net (Dirk Mueller)
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Dec 2006 18:35:24 -0500 (EST)
- Subject: Re: [PATCH] Fix PR/8268: implement compile time array subscript checking
>
>
> Hi,
>
> The patch below implements PR/8268, which seems to be the one major diagnostic
> we're missing compared to icc (at least one openSUSE contributor regularly
> rebuilds all of the openSUSE distribution with icc just to report those
> warnings as bugs to us ;) ).
>
> bootstrapped and regtested with no additional failures many times on
> i686-suse-linux.
>
> Ok? Do we need the extra -Warray-bounds?
Your documentation for the warning is incorrect as
you say:
> +This option is only active when @option{-O1} or higher is active. It warns
> +about constant subscripts in array accesses that are out of bounds.
But that is wrong as it is actived only with -O1 -ftree-vrp or -O2 and higher
with VRP still turned on.
Second I would not just set it for the C family of languages:
> --- c-opts.c (revision 119391)
> +++ c-opts.c (working copy)
> @@ -396,6 +396,7 @@ c_common_handle_option (size_t scode, co
> warn_strict_aliasing = value;
> warn_string_literal_comparison = value;
> warn_always_true = value;
> + warn_array_bounds = value;
Third how well does the current VRP implentation handle:
int v[10]={0};
void f(void)
{
int n = 99;
int i;
if (n <= 0)
return;
if (n > 0)
{
i = 1;
do {
/* _Bool t = i <= 0;
_Bool t1 = i > n;
_Bool t2 = t || t1;
if (t2) __builtin_abort (); */
v[i] = i*i;
i++;
} while (i != n);
}
}
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.
Thanks,
Andrew Pinski