1 // RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-PLAIN 2 // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t 3 // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL 4 5 // FIXME: UBSan fails to add the correct instrumentation code for some reason on 6 // Windows. 7 // XFAIL: win32 8 9 enum E { a = 1 } e; 10 #undef E 11 12 int main(int argc, char **argv) { 13 // memset(&e, 0xff, sizeof(e)); 14 for (unsigned char *p = (unsigned char*)&e; p != (unsigned char*)(&e + 1); ++p) 15 *p = 0xff; 16 17 // CHECK-PLAIN: error: load of value 4294967295, which is not a valid value for type 'enum E' 18 // FIXME: Support marshalling and display of enum class values. 19 // CHECK-BOOL: error: load of value <unknown>, which is not a valid value for type 'enum E' 20 return (int)e != -1; 21 } 22