Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr71792.C

raw
1 // { dg-do run { target c++11 } }
2 // PR C++/71792
3
4 class some_class
5 {
6 public:
7 unsigned int np : 4;
8 unsigned int nc : 8;
9 unsigned int nc0 : 1;
10 };
11
12 template<bool what>
13 static void test_bug (const some_class &mp) {
14 if (what) {
15 int t = 0;
16 for (auto i = mp.nc0; i < mp.nc; i++) {
17 if (t != i) __builtin_abort ();
18 t++;
19 }
20 }
21 }
22
23 static void test_ok (const some_class &mp) {
24 int t = 0;
25 for (auto i = mp.nc0; i < mp.nc; i++) {
26 if (t != i) __builtin_abort ();
27 t++;
28 }
29 }
30
31 int main ()
32 {
33 some_class mp;
34 mp.nc0 = 0;
35 mp.nc = 9;
36 mp.np = 3;
37
38 test_bug<true> (mp);
39 test_ok (mp);
40
41 return 0;
42 }