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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Created attachment 46771
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46771&action=edit
A proof-of-concept implementation of the overflow detection.

With the attached proof of concept GCC diagnoses the first overflow:

x.c: In function ‘f’:
x.c:8:3: warning: ‘strcpy’ writing 5 bytes into a region of size between 0 and
4 [-Wstringop-truncation]
    8 |   strcpy (t, a);
      |   ^~~~~~~~~~~~~
x.c:7:20: note: region allocated by ‘malloc’ here
    7 |   char *t = (char*)malloc (strlen (a));
      |                    ^~~~~~~~~~~~~~~~~~~

Reply via email to