https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110914
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 55813 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55813&action=edit gcc14-pr110914.patch Untested fix. The bogus change in the above mentioned commit was the: if (olddsi != NULL - && tree_fits_uhwi_p (len) && !integer_zerop (len)) - adjust_last_stmt (olddsi, stmt, false); + { + maybe_warn_overflow (stmt, len, rvals, olddsi, false, true); + adjust_last_stmt (olddsi, stmt, false); + } part. I haven't analyzed what exactly maybe_warn_overflow does, it is some warning stuff and perhaps can be called when len is not constant, but the previous guarding of adjust_last_stmt was completely intentional. As adjust_last_stmt function comment says: If the last .MEM setter statement before STMT is memcpy (x, y, strlen (y) + 1), the only .MEM use of it is STMT and STMT is known to overwrite x[strlen (x)], adjust the last memcpy to just memcpy (x, y, strlen (y)). SI must be the zero length strinfo. so obviously the fact that memcpy (the second one) doesn't have last argument constant 0 doesn't mean that it is non-zero length memcpy, we only know it either if it is constant non-zero length, or variable where say value-range could prove it is not zero. We have an adjust_last_stmt call later in the function which handles length of strlen (x) + 1 though. So, this patch just reverts the guard of that function back to what it was before.