[PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 14:04:30 PDT 2019
- Previous message: [PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0
- Next message: [PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
lebedev.ri added a comment.
In D67986#1692020 <https://reviews.llvm.org/D67986#1692020>, @efriedma wrote:
> Oh, hmm... actually, just realized something; is the new formulation actually equivalent? Specifically, is it okay to write to "d[size - 1]" if the string is short? 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.
Sounds like this should be guarded to only work for simple (non-volatile, non-atomic) pointers?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67986/new/
https://reviews.llvm.org/D67986
- Previous message: [PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0
- Next message: [PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the llvm-commits
mailing list