https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84383
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 43415 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43415&action=edit gcc8-pr84383.patch Untested fix. BTW, the code is still problematic, e.g. the: if (code == ARRAY_REF || code == MEM_REF) lhs = TREE_OPERAND (lhs, 0); For MEM_REF, TREE_OPERAND (lhs, 0) is either ADDR_EXPR of some decl, or an SSA_NAME, I can understand what you can do with the SSA_NAME (for the stpncpy result comparison which will also be a SSA_NAME), but other than that it is then apples vs. oranges e.g. in the get_addr_base_and_unit_offset calls. Also, the comment says: /* Look for dst[i] = '\0'; after the stxncpy() call and if found avoid the truncation warning. */ but you aren't testing for that, but rather that there is any kind of assignment after the strncpy call (no check that the rhs of the next_stmt is integer_zerop).