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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|RESOLVED                    |NEW
   Last reconfirmed|                            |2014-09-11
                 CC|                            |manu at gcc dot gnu.org
         Resolution|INVALID                     |---
            Summary|Valid out of bounds access  |Missing Warray-bounds
                   |leads to undefined behavior |warning for array within
                   |                            |struct
     Ever confirmed|0                           |1

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
This should be warned by Warray-bounds. Clang warns even at -O0, so this case
can even be warned in the FE:

test.c:10:3: warning: array index 1 is past the end of the array (which
contains 1 element) [-Warray-bounds]
  foo.a[1] = 99;
  ^     ~
test.c:2:3: note: array 'a' declared here
  int a[1];
  ^
test.c:12:10: warning: array index 1 is past the end of the array (which
contains 1 element) [-Warray-bounds]
  return foo.a[1];
         ^     ~
test.c:2:3: note: array 'a' declared here
  int a[1];
  ^

Reply via email to