[Bug middle-end/77696] Confusing wording for -Wformat-overflow
dmalcolm at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 13 13:16:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77696
--- Comment #11 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #5)
> I brainstormed some ideas on making these kinds of warning easier for
> the user to understand.
A simple example where the overflowing write is to the start of the
buffer:
sprintf of an unbounded string to a fixed-size buf[100]:
demo.c:6:3: note: buffer overflow...
snprintf of "%s" from:
|+------+|+--------------++-------+|
||0...99|||100...strlen-1|| strlen||
|| ||| || NUL ||
|+------+|+--------------++-------+|
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|<--ok-->|<-- overflow -->|
| | |
to 'buf':
| |
|+------+|
||0...99||
|+------+|
More information about the Gcc-bugs
mailing list