| 1 | // RUN: %clangxx_msan -fsanitize-recover=memory -mllvm -msan-instrumentation-with-call-threshold=0 -g %s -o %t \ |
| 2 | // RUN: && not env MSAN_OPTIONS=verbosity=1 %run %t 2>&1 | FileCheck %s |
| 3 | |
| 4 | // REQUIRES: x86_64-target-arch |
| 5 | // 'long double' implementation varies between platforms. |
| 6 | |
| 7 | #include <ctype.h> |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | #include <sanitizer/msan_interface.h> |
| 11 | |
| 12 | int main(int argc, char *argv[]) { |
| 13 | long double a; |
| 14 | printf(format: "a: %Lf\n" , a); |
| 15 | // CHECK: Shadow value (16 bytes): ffffffff ffffffff ffff0000 00000000 |
| 16 | |
| 17 | unsigned long long b; |
| 18 | printf(format: "b: %llu\n" , b); |
| 19 | // CHECK: Shadow value (8 bytes): ffffffff ffffffff |
| 20 | |
| 21 | char *p = (char *)(&b); |
| 22 | p[2] = 36; |
| 23 | printf(format: "b: %lld\n" , b); |
| 24 | // CHECK: Shadow value (8 bytes): ffff00ff ffffffff |
| 25 | |
| 26 | b = b << 8; |
| 27 | printf(format: "b: %lld\n" , b); |
| 28 | __msan_print_shadow(x: &b, size: sizeof(b)); |
| 29 | // CHECK: Shadow value (8 bytes): 00ffff00 ffffffff |
| 30 | |
| 31 | unsigned int c; |
| 32 | printf(format: "c: %u\n" , c); |
| 33 | // CHECK: Shadow value (4 bytes): ffffffff |
| 34 | |
| 35 | // Converted to boolean |
| 36 | if (c) { |
| 37 | // CHECK: Shadow value (1 byte): 01 |
| 38 | printf(format: "Hello\n" ); |
| 39 | } |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |