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

--- Comment #17 from Martin Sebor <msebor at gcc dot gnu.org> ---
Just for reference, GCC goes to a lot of trouble to diagnose this sort of thing
and issues one of three warnings for this code, depending on which one is
enabled.  The first two are issued by the wrestrict pass, the last one just
before expansion in builtins.c.  The last one looks pretty good, so I'll see if
I can coax the wrestrict pass into printing something like it or into simply
deferring these kinds of warnings to -Wstringop-overflow if it's enabled.

By default GCC issues:

‘__builtin_strncpy’ pointer overflow between offset 0 and size [-1,
9223372036854775807] [-Warray-bounds]

with -Wno-array-bounds it says:

‘__builtin_strncpy’ accessing 18446744073709551615 or more bytes at offsets 0
and 0 may overlap up to 9223372036854775808 bytes at offset
-9223372036854775808 [-Wrestrict]

and with -Wno-restrict:

‘__builtin_strncpy’ specified size 18446744073709551615 exceeds maximum object
size 9223372036854775807 [-Wstringop-overflow=]

Reply via email to