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||
  |+------+|

Reply via email to