[Bug middle-end/77696] Confusing wording for -Wformat-overflow

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 13 13:23:00 GMT 2018


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

--- Comment #14 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Another example from Martin:

   extern char buf[80];
   extern char tmpdir[80];
   extern char fname[8];

   void f (int num)
   {
     sprintf (buf, "/%s/%s-%i.tmp", tmpdir, fname, num);
   }

In the most basic case (nothing beyond what's in the above is
known) GCC currently prints the rather mystifying:

   warning: ‘/’ directive writing 1 byte into a region of size between 0 
and 79 [-Wformat-overflow=]
   7 |   __builtin_sprintf (buf, "/%s/%s-%i.tmp", tmpdir, fname, num);
     |                               ^

We need to make this more "actionable" for the end-user.


More information about the Gcc-bugs mailing list