https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77696
--- Comment #12 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. Copying a string to a buffer allocated with strlen(), rather than strlen() + 1: | | | |+----------------+|+--------+| ||0...strlen() - 1|| NUL || |+----------------+|+--------+| vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |<--- ok -->|<overflow>| | | | to 'buf': | | |+----------------+| ||0...strlen() - 1|| |+----------------+| (drawing the user's attention to the NUL terminator, because it's such a common source of mistakes) FWIW, I have some classes for laying out ASCII art drawings which could be reused for this, as part of this vectorization RFC: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg01576.html