Martin Sebor <msebor at gcc dot> changed:

           What    |Removed                     |Added
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |msebor at gcc dot
         Resolution|---                         |WONTFIX
            Summary|Unexpected                  |Unexpected
                   |-Wstringop-truncation       |-Wstringop-truncation on
                   |                            |strncpy with string literal

--- Comment #1 from Martin Sebor <msebor at gcc dot> ---
This is among the unavoidable cases I was referring to in bug 84468.   The
strcpy call with constant arguments is folded into memcpy too early to see the
subsequent assignment of the NUL.  I argued to defer this early folding because
it tends to defeat downstream optimizations but I lost.

I would make the argument (and have) that in the test case, strncpy is being
misused and strcpy (or other string functions if strcpy is not acceptable)
would be more appropriate.

If you have a test case with the inlining please open a new bug.  It may not
get fixed for GCC 8 but it might serve as an argument for deferring folding
these calls until more context is available, or for other solutions.

Reply via email to