Summary: As per the test the 4th element of both arrays are not initialized and hence will contain garbage values. Memcmp returns the difference between the garbage values of the 4th element which will be different on every run of the test. And since the return value of memcmp is returned from main, we are getting random exit code every time. Reviewers: kcc, eugenis Subscribers: mohit.bhakkad, jaydeep, llvm-commits Differential: http://reviews.llvm.org/D17534 llvm-svn: 261739
19 lines
491 B
C++
19 lines
491 B
C++
// RUN: %clangxx_msan -O0 -g %s -o %t
|
|
// RUN: not %run %t 2>&1 | FileCheck %s
|
|
// RUN: MSAN_OPTIONS=intercept_memcmp=0 %run %t
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
int main(int argc, char **argv) {
|
|
char a1[4];
|
|
char a2[4];
|
|
for (int i = 0; i < argc * 3; i++)
|
|
a2[i] = a1[i] = i;
|
|
int res = memcmp(a1, a2, 4);
|
|
if (!res)
|
|
printf("equals");
|
|
return 0;
|
|
// CHECK: Uninitialized bytes in __interceptor_memcmp at offset 3
|
|
// CHECK: MemorySanitizer: use-of-uninitialized-value
|
|
}
|