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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
             Blocks|88443                       |97048
             Status|NEW                         |RESOLVED
      Known to fail|10.0                        |10.2.0
      Known to work|                            |11.0
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org
            Summary|missing -Wstringop-overflow |missing -Wstringop-overread
                   |reading past the end of a   |reading past the end of a
                   |string                      |string

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 11 diagnoses all instances of the problem with the new -Wstringop-overead
warning, both in the test case in comment #0 as well in comment #4:

$ gcc -O2 -S pr81437.c
pr81437.c: In function ‘f’:
pr81437.c:5:3: warning: ‘__builtin_memcpy’ reading between 1 and 4294967295
bytes from a region of size 0 [-Wstringop-overread]
    5 |   __builtin_memcpy (d, a + 4, n);   // warning (ok)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr81437.c:3:14: note: at offset 4 into source object ‘a’
    3 |   const char a[] = "123";
      |              ^
pr81437.c: In function ‘g’:
pr81437.c:12:3: warning: ‘__builtin_memcpy’ reading 1 byte from a region of
size 0 [-Wstringop-overread]
   12 |   __builtin_memcpy (d, a + 4, n);   // missing warning
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr81437.c:10:14: note: at offset 4 into source object ‘a’
   10 |   const char a[] = "123";
      |              ^
pr81437.c: In function ‘h’:
pr81437.c:18:3: warning: ‘__builtin_strcpy’ reading 1 or more bytes from a
region of size 0 [-Wstringop-overread]
   18 |   __builtin_strcpy (d, a + 4);   // missing warning
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
pr81437.c:17:14: note: at offset 4 into source object ‘a’
   17 |   const char a[] = "123";
      |              ^
pr81437.c: In function ‘fx’:
pr81437.c:26:10: warning: ‘__builtin_strcmp’ reading between 1 and 4 bytes from
a region of size 0 [-Wstringop-overread]
   26 |   return __builtin_strcmp (a, &a[4]);   // missing warning
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
pr81437.c:22:6: note: at offset 4 into source object ‘a’
   22 | char a[4];
      |      ^
pr81437.c: In function ‘gx’:
pr81437.c:31:10: warning: ‘__builtin_puts’ reading between 1 and 4 bytes from a
region of size 0 [-Wstringop-overread]
   31 |   return __builtin_puts (&a[4]);   // missing warning
      |          ^~~~~~~~~~~~~~~~~~~~~~
pr81437.c:22:6: note: at offset 4 into source object ‘a’
   22 | char a[4];
      |      ^
pr81437.c: In function ‘fc4’:
pr81437.c:26:10: warning: ‘__builtin_strcmp’ reading between 1 and 4 bytes from
a region of size 0 [-Wstringop-overread]
   26 |   return __builtin_strcmp (a, &a[4]);   // missing warning
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
pr81437.c:22:6: note: at offset 4 into source object ‘a’
   22 | char a[4];
      |      ^
pr81437.c: In function ‘gc4’:
pr81437.c:31:10: warning: ‘__builtin_puts’ reading between 1 and 4 bytes from a
region of size 0 [-Wstringop-overread]
   31 |   return __builtin_puts (&a[4]);   // missing warning
      |          ^~~~~~~~~~~~~~~~~~~~~~
pr81437.c:22:6: note: at offset 4 into source object ‘a’
   22 | char a[4];
      |      ^


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97048
[Bug 97048] [meta-bug] bogus/missing -Wstringop-overread warnings

Reply via email to