[Bug tree-optimization/96951] strncpy truncation warning does not recognize truncation check

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Sep 7 10:04:35 GMT 2020


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With the exception of code that needs to ensure the rest of the buffer is
filled with zeros (typically code dealing with passwords etc.), strncpy is
pretty much never something one should use.  Even the above example, if it is
only meant to truncate and return -1 if it doesn't fit, but otherwise just copy
the string, is wasting time on the extra clearing (sure, when it is just 10
bytes that isn't that big deal).


More information about the Gcc-bugs mailing list