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

            Bug ID: 95461
           Summary: GCC misses -Warray-bounds warning message
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

#include<iostream>
int main () {
    int a[10] = {0};
    a[11] = 0;
    std::cout << "ok" << std::endl;
    return 0;
}

produce nothing in gcc-trunk.


While in clang

$clang++ test.cc
test.cc:4:5: warning: array index 11 is past the end of the array (which
contains 10 elements) [-Warray-bounds]
    a[11] = 0;
    ^ ~~
test.cc:3:5: note: array 'a' declared here
    int a[10] = {0};
    ^
1 warning generated.


My gcc version is 
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

All GCC versions have this missing.

Reply via email to