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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-01-08

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this report.

As I understand it, snprintf can accept a NULL destination argument when the
size is zero, but otherwise the destination argument must be non-NULL.

Hence (as you note), we can't simply add the __nonnull__ attribute to the
declaration.

Currently the analyzer doesn't have any special-case knowledge of the behavior
of sprintf.  Looks like we should add it.  In particular, looks like we should
model the write to the destination buffer (and thus require the non-NULL-ness
of the pointer for the known non-zero size case).

See also RFE 105102.

Reply via email to