https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102462

            Bug ID: 102462
           Summary: vectorizer breaks diagnostic for array out of bound
                    detect.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

> > Yes, there are quite a few warning tests like that.  Their main
> > purpose is to verify that in common GCC invocations (i.e., without
> > any special options) warnings are a) issued when expected and b)
> > not issued when not expected.  Otherwise, middle end warnings are
> > known to have both false positives and false negatives in some
> > invocations, depending on what optimizations are in effect.
> > Indiscriminately disabling common optimizations for these large
> > tests and invoking them under artificial conditions would
> > compromise this goal and hide the problems.
> >
> > If enabling vectorization at -O2 causes regressions in the quality
> > of diagnostics (as the test failure above indicates seems to be
> > happening) we should investigate these and open bugs for them so
> > they can be fixed.  We can then tweak the specific failing test
> > cases to avoid the failures until they are fixed.

There're 3 cases.

1. All accesses are out of bound, and after vectorization, there are
some warnings missing.(Because there only 1 access after vectorization, 2
accesses w/o vectorization, and diagnostic is based on access).
2. Part of accesses are inbound, part of accesses are out of bound,
and after vectorization, the warning goes from out of bound line to
inbound line.
3. All access are out of bound, and after vectoriation, all warning
are missing, and goes to a false-positive line.


below is case3:

> void ga1i_1 (void)
> {
>   a1i_1.a[0] = 0;
>   a1i_1.a[1] = 1;               // { dg-warning "\\\[-Wstringop-overflow" }
>   a1i_1.a[2] = 2;               // { dg-warning "\\\[-Wstringop-overflow" }
>
>   struct A1 a = { 0, { 1 } }; --- false positive here.
>   a.a[0] = 1;
>   a.a[1] = 2;                   // { dg-warning "\\\[-Wstringop-overflow" } 
> false negative here.
>   a.a[2] = 3;                   // { dg-warning "\\\[-Wstringop-overflow" } 
> false negative here.
>   sink (&a);
> }


Related testcases.

            * c-c++-common/Wstringop-overflow-2.c
            * gcc.dg/Warray-bounds-51.c: Ditto.
            * gcc.dg/Wstringop-overflow-14.c: Ditto.
            * gcc.dg/Wstringop-overflow-21.c: Ditto.

Reply via email to