[PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 14:17:39 PDT 2019


xbolva00 added a comment.

>> Say, for example, you have something like snprintf(buf, 10, "%s", "x"). That normally writes to two elements of the array: 0 and 1. The rewritten version writes to three elements: 0, 1, and 9.

Hm, this is right. We overwrite d[size -1] always, which is bad. I have no more ideas, probably we can do nothing, just abandon this transformation.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67986/new/

https://reviews.llvm.org/D67986





More information about the llvm-commits mailing list