The warning suppression for -Wstringop-truncation looks for the next statement after a truncating strncpy to see if it adds a terminating nul. This only works when the next statement can be reached using the Gimple statement iterator which isn't until after gimplification. As a result, strncpy calls that truncate their constant argument that are being folded to memcpy this early get diagnosed even if they are followed by the nul assignment: const char s[] = "12345"; char d[3]; void f (void) { strncpy (d, s, sizeof d - 1); // -Wstringop-truncation d[sizeof d - 1] = 0; } To avoid the warning I propose to defer folding strncpy to memcpy until the pointer to the basic block the strnpy call is in can be used to try to reach the next statement (this happens as early as ccp1). I'm aware of the preference to fold things early but in the case of strncpy (a relatively rarely used function that is often misused), getting the warning right while folding a bit later but still fairly early on seems like a reasonable compromise. I fear that otherwise, the false positives will drive users to adopt other unsafe solutions (like memcpy) where these kinds of bugs cannot be as readily detected. Tested on x86_64-linux. Martin PS There still are outstanding cases where the warning can be avoided. I xfailed them in the test for now but will still try to get them to work for GCC 9.