xref: /aosp_15_r20/external/compiler-rt/test/ubsan/TestCases/Misc/bool.cpp (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx -fsanitize=bool %s -O3 -o %t
2*7c3d14c8STreehugger Robot // RUN: not %run %t 2>&1 | FileCheck %s
3*7c3d14c8STreehugger Robot // RUN: %env_ubsan_opts=print_summary=1:report_error_type=1 not %run %t 2>&1 | FileCheck %s --check-prefix=SUMMARY
4*7c3d14c8STreehugger Robot 
5*7c3d14c8STreehugger Robot unsigned char NotABool = 123;
6*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)7*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
8*7c3d14c8STreehugger Robot   bool *p = (bool*)&NotABool;
9*7c3d14c8STreehugger Robot 
10*7c3d14c8STreehugger Robot   // CHECK: bool.cpp:[[@LINE+1]]:10: runtime error: load of value 123, which is not a valid value for type 'bool'
11*7c3d14c8STreehugger Robot   return *p;
12*7c3d14c8STreehugger Robot   // SUMMARY: SUMMARY: {{.*}}Sanitizer: invalid-bool-load {{.*}}bool.cpp:[[@LINE-1]]
13*7c3d14c8STreehugger Robot }
14