This is the mail archive of the 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] 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)
  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;

      } 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

Andrew Pinski

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