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

            Bug ID: 91146
           Summary: -Werror=array-bounds if compile with
                    -fsanitize=address
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: grishalipenko at protonmail dot com
  Target Milestone: ---

Created attachment 46592
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46592&action=edit
gtest llvm small_vector

It's google test for llvm small_vector.
Compile: g++ -Wall -Wextra -O2 -Werror -fsanitize=address -c main.cpp
And get:

small_vector.h:505:7: ошибка: array subscript 1 is outside array bounds of «int
[1]» [-Werror=array-bounds]
  505 |       ++EltPtr;
      |       ^~
main.cpp:7:26: замечание: while referencing «<anonymous>»
    7 |   v.insert (v.begin (), 1);
      | 

If compile "g++ -Wall -Wextra -O2 -Werror -c main.cpp" there is no warning.

I don't have this problem with gcc 8.3.0 .
I compiled my project with gcc 9.1.0 without optimization and sanitizer don't
detect problems in runtime.

Reply via email to