c++: P0847R7 (deducing this) - xobj lambdas. [PR102609]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / bit-cast14.C
blobe0cc9a3970270a8a1b79fe8d00aa44902bb1fe12
1 // P1272R4
2 // { dg-do compile { target c++14 } }
4 struct S { unsigned char a : 8, b : 5, c : 3, d, e; unsigned int f : 8, g : 24; };
5 struct T1 { unsigned char a : 1, : 7, b : 5, c : 3, d, e; unsigned int f : 8, g : 24; };
6 struct T2 { unsigned char a : 8, b : 1, : 4, c : 3, d, e; unsigned int f : 8, g : 24; };
7 struct T3 { unsigned char a : 8, b : 5, c : 1, : 2, d, e; unsigned int f : 8, g : 24; };
8 struct T4 { unsigned char a : 8, b : 5, c : 3, d, e; unsigned int f : 1, : 7, g : 24; };
10 constexpr bool
11 f1 ()
13   T1 t = { 0, 0, 0, 0, 0, 0, 0 };
14   S s = __builtin_bit_cast (S, t);
15   return true;
18 constexpr bool
19 f2 ()
21   T2 t = { 0, 0, 0, 0, 0, 0, 0 };
22   S s = __builtin_bit_cast (S, t);
23   return true;
26 constexpr bool
27 f3 ()
29   T3 t = { 0, 0, 0, 0, 0, 0, 0 };
30   S s = __builtin_bit_cast (S, t);
31   return true;
34 constexpr bool
35 f4 ()
37   T4 t = { 0, 0, 0, 0, 0, 0, 0 };
38   S s = __builtin_bit_cast (S, t);      // { dg-error "accessing uninitialized byte" }
39   return true;
42 constexpr bool
43 f5 ()
45   T1 t = { 0, 0, 0, 0, 0, 0, 0 };
46   S s = __builtin_bit_cast (S, t);
47   unsigned char a = s.a;                // { dg-error "accessing uninitialized member" }
48   return true;
51 constexpr bool
52 f6 ()
54   T2 t = { 0, 0, 0, 0, 0, 0, 0 };
55   S s = __builtin_bit_cast (S, t);
56   unsigned char b = s.b;                // { dg-error "accessing uninitialized member" }
57   return true;
60 constexpr bool
61 f7 ()
63   T3 t = { 0, 0, 0, 0, 0, 0, 0 };
64   S s = __builtin_bit_cast (S, t);
65   unsigned char c = s.c;                // { dg-error "accessing uninitialized member" }
66   return true;
69 constexpr bool a = f1 ();
70 constexpr bool b = f2 ();
71 constexpr bool c = f3 ();
72 constexpr bool d = f4 ();       // { dg-message "in .constexpr. expansion" }
73 constexpr bool e = f5 ();       // { dg-message "in .constexpr. expansion" }
74 constexpr bool f = f6 ();       // { dg-message "in .constexpr. expansion" }
75 constexpr bool g = f7 ();       // { dg-message "in .constexpr. expansion" }