1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=bool,enum" } */
3 
4 #ifndef __cplusplus
5 #define bool _Bool
6 #endif
7 enum A { B = -3, C = 2 } a;
8 bool b;
9 
10 __attribute__((noinline, noclone)) enum A
foo(bool * p)11 foo (bool *p)
12 {
13   *p = b;   /* { dg-output "load-bool-enum.c:13:\[^\n\r]*runtime error: \[^\n\r]*load of value 4, which is not a valid value for type '(_B|b)ool'\[^\n\r]*(\n|\r\n|\r)*" } */
14   return a; /* { dg-output "\[^\n\r]*load-bool-enum.c:14:\[^\n\r]*runtime error: \[^\n\r]*load of value 9, which is not a valid value for type 'A'" { target c++ } } */
15 }
16 
17 int
main()18 main ()
19 {
20   char c = 4;
21   int d = 9;
22   if (sizeof (int) != sizeof (a) || sizeof (b) != 1)
23     return 0;
24   __builtin_memcpy (&a, &d, sizeof (int));
25   __builtin_memcpy (&b, &c, 1);
26   bool e;
27   foo (&e);
28   return 0;
29 }
30