https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79220
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=83508
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
In GCC 8.0 the overflow is diagnosed in both functions. In f() by
-Wstringop-overflow as before, and in both functions (perhaps surprisingly) by
the newly enhanced -Warray-bounds warning (r255755). There is still no
-Wstringop-overflow for g() so the limitation hasn't really been removed yet
and this bug should stay open until it is, and until the overflow in g() is
diagnosed -Wstringop-overflow when -Warray-bounds is disabled.
As an aside, the -Wstringop-overflow for f() will disappear if/when the patch
submitted for bug 83508 is committed.
pr79220.c: In function ‘g’:
pr79220.c:12:3: warning: ‘memcpy’ forming offset [4, 8] is out of the bounds
[0, 3] of object ‘d’ with type ‘char[3]’ [-Warray-bounds]
memcpy (d, s, 8);
^~~~~~~~~~~~~~~~
pr79220.c:3:6: note: ‘d’ declared here
char d[3];
^
pr79220.c: In function ‘f’:
pr79220.c:7:3: warning: ‘memcpy’ forming offset [4, 8] is out of the bounds [0,
3] of object ‘d’ with type ‘char[3]’ [-Warray-bounds]
memcpy (d, "0123456789", 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
pr79220.c:3:6: note: ‘d’ declared here
char d[3];
^
pr79220.c:7:3: warning: ‘memcpy’ writing 8 bytes into a region of size 3
overflows the destination [-Wstringop-overflow=]
memcpy (d, "0123456789", 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~