Debian Codegraph @

gcc/testsuite/gdc.dg/torture/gdc171.d

raw
1 // https://bugzilla.gdcproject.org/show_bug.cgi?id=171
2 // { dg-do run }
3 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
4
5 void test171a()
6 {
7 int count = 0;
8 short a = -1;
9 while (a != 0)
10 {
11 a >>>= 1;
12 count++;
13 assert(count <= 16);
14 }
15 }
16
17 void test171b()
18 {
19 uint[3] lhs = [99, 201, 300],
20 rhs = [-1, 0, 0];
21 long t = 0;
22
23 for (int i = 0; i < 3; i++)
24 {
25 t += lhs[i];
26 t -= rhs[i];
27 lhs[i] = cast(uint) t;
28 t >>= uint.sizeof * 8;
29 }
30
31 assert(lhs == [100, 200, 300]);
32 }
33
34 void main()
35 {
36 test171a();
37 test171b();
38 }