1// RUN: %clang -fsanitize=bool %s -O3 -o %t
2// RUN: not %run %t 2>&1 | FileCheck %s
3// RUN: %env_ubsan_opts=print_summary=1:report_error_type=1 not %run %t 2>&1 | FileCheck %s --check-prefix=SUMMARY
4
5typedef char BOOL;
6unsigned char NotABool = 123;
7
8int main(int argc, char **argv) {
9 BOOL *p = (BOOL*)&NotABool;
10
11 // CHECK: bool.m:[[@LINE+1]]:10: runtime error: load of value 123, which is not a valid value for type 'BOOL'
12 return *p;
13 // SUMMARY: SUMMARY: {{.*}}Sanitizer: invalid-bool-load {{.*}}bool.m:[[@LINE-1]]
14}
15

source code of compiler-rt/test/ubsan/TestCases/Misc/bool.m