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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-12-14
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  Exceeding the size of the destination should be diagnosed.  This is
an easy change to make.

The second problem could and arguably should be detected by
-Wsizeof-pointer-memaccess as it is for functions like strncpy().  It looks
like the warning has all the smarts to do it except for a small limitation in
the sizeof_pointer_memaccess_warning() function.  To detect this problem the
function would need to iterate over snprintf arguments starting with the first
one after the format string, and check each for equality to sizeof_arg[idx]. 
This also looks easy but should probably be made as a separate change from the
above (and tracked by a separate bug).

Reply via email to