| 1 | // RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=strict_memcmp=0 %run %t |
| 2 | // RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=strict_memcmp=1 not %run %t 2>&1 | FileCheck %s |
| 3 | // Default to strict_memcmp=1. |
| 4 | // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include <string.h> |
| 8 | int main() { |
| 9 | char kFoo[] = "foo" ; |
| 10 | char kFubar[] = "fubar" ; |
| 11 | int res = memcmp(s1: kFoo, s2: kFubar, n: strlen(s: kFubar)); |
| 12 | printf(format: "res: %d\n" , res); |
| 13 | // CHECK: AddressSanitizer: stack-buffer-overflow |
| 14 | return 0; |
| 15 | } |
| 16 | |