llvm/compiler-rt/test/msan/strcmp.c
Vitaly Buka 516d757432 [msan][asan] Add runtime flag intercept_strcmp
Can be used to disable interceptor to workaround issues of
non-instrumented code.

Reviewed By: morehouse, eugenis

Differential Revision: https://reviews.llvm.org/D87897
2020-09-18 13:45:55 -07:00

21 lines
549 B
C

// RUN: %clang_msan %s -o %t
// RUN: MSAN_OPTIONS=intercept_strcmp=false %run %t 2>&1
// RUN: MSAN_OPTIONS=intercept_strcmp=true not %run %t 2>&1 | FileCheck %s
// RUN: not %run %t 2>&1 | FileCheck %s
#include <assert.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
char undef;
char s1[] = "abcd";
char s2[] = "1234";
assert(strcmp(s1, s2) > 0);
s2[0] = undef;
assert(strcmp(s1, s2));
// CHECK: {{.*WARNING: MemorySanitizer: use-of-uninitialized-value}}
return 0;
}