1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker=core,alpha.unix.cstring
5 // This file is generally for the alpha.unix.cstring.UninitializedRead Checker, the reason for putting it into
6 // the separate file because the checker is break the some existing test cases in bstring.c file , so we don't
7 // wanna mess up with some existing test case so it's better to create separate file for it, this file also include
8 // the broken test for the reference in future about the broken tests.
11 typedef typeof(sizeof(int)) size_t;
13 void clang_analyzer_eval(int);
15 void *memcpy(void *restrict s1
, const void *restrict s2
, size_t n
);
19 memcpy(dst
, buf
, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
23 //===----------------------------------------------------------------------===
25 //===----------------------------------------------------------------------===
27 void *mempcpy(void *restrict s1
, const void *restrict s2
, size_t n
);
30 int src
[] = {1, 2, 3, 4};
34 p
= mempcpy(dst
, src
, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
35 // FIXME: This behaviour is actually surprising and needs to be fixed,
36 // mempcpy seems to consider the very last byte of the src buffer uninitialized
37 // and returning undef unfortunately. It should have returned unknown or a conjured value instead.
39 clang_analyzer_eval(p
== &dst
[4]); // no-warning (above is fatal)
55 p2
= mempcpy(&s2
, &s1
, sizeof(struct st
)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
56 // FIXME: It seems same as mempcpy14() case.
58 clang_analyzer_eval(p1
== p2
); // no-warning (above is fatal)