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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |10.0
         Resolution|---                         |FIXED

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed in GCC 10 which now issues the warnings below by default (without -Wall
or other options):

pr79016.c: In function ‘fauto’:
pr79016.c:7:3: warning: ‘__builtin_memset’ forming offset [3, 4] is out of the
bounds [0, 3] of object ‘d’ with type ‘char[3]’ [-Warray-bounds]
    7 |   f (__builtin_memset (d, 0, 5));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79016.c:5:8: note: ‘d’ declared here
    5 |   char d[3];
      |        ^
pr79016.c: In function ‘funnamed’:
pr79016.c:12:3: warning: ‘__builtin_memset’ forming offset [3, 4] is out of the
bounds [0, 3] of object ‘({anonymous})’ with type ‘char[3]’ [-Warray-bounds]
   12 |   f (__builtin_memset ((char[3]){ 0 }, 1, 5));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79016.c:12:33: note: ‘({anonymous})’ declared here
   12 |   f (__builtin_memset ((char[3]){ 0 }, 1, 5));
      |                                 ^
pr79016.c: In function ‘falloca’:
pr79016.c:19:3: warning: ‘__builtin_memset’ writing 5 bytes into a region of
size 3 [-Wstringop-overflow=]
   19 |   f (__builtin_memset (d, 0, 5));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79016.c:17:13: note: at offset 0 to an object with size 3 allocated by
‘__builtin_alloca’ here
   17 |   char *d = __builtin_alloca (3);
      |             ^~~~~~~~~~~~~~~~~~~~
pr79016.c: In function ‘fmalloc’:
pr79016.c:26:3: warning: ‘__builtin_memset’ writing 5 bytes into a region of
size 3 [-Wstringop-overflow=]
   26 |   f (__builtin_memset (d, 0, 5));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79016.c:24:13: note: at offset 0 to an object with size 3 allocated by
‘__builtin_malloc’ here
   24 |   char *d = __builtin_malloc (3);
      |             ^~~~~~~~~~~~~~~~~~~~
pr79016.c: In function ‘fvla’:
pr79016.c:36:3: warning: ‘__builtin_memset’ writing 5 bytes into a region of
size between 0 and 3 [-Wstringop-overflow=]
   36 |   f (__builtin_memset (d, 0, 5));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79016.c:34:8: note: at offset 0 to an object with size at most 3 declared
here
   34 |   char d [n];
      |        ^

Reply via email to