[clang] [analyzer] Check the correct first and last elements in cstring.UninitializedRead (PR #95408)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 08:32:08 PDT 2024
================
@@ -26,16 +50,12 @@ void top(char *dst) {
void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
-void mempcpy14() {
+void mempcpy13() {
int src[] = {1, 2, 3, 4};
int dst[5] = {0};
int *p;
- p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
- // FIXME: This behaviour is actually surprising and needs to be fixed,
- // mempcpy seems to consider the very last byte of the src buffer uninitialized
- // and returning undef unfortunately. It should have returned unknown or a conjured value instead.
-
+ p = mempcpy(dst, src, 4 * sizeof(int));
clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
----------------
NagyDonat wrote:
Delete or update the comment on this line.
https://github.com/llvm/llvm-project/pull/95408
More information about the cfe-commits
mailing list