d: Merge upstream dmd 568496d5b, druntime 178c44ff, phobos 574bf883b.
[official-gcc.git] / gcc / testsuite / gdc.test / compilable / test21794.d
blob68e504bce5606822aba4088a9be7c54973bb18d8
1 // https://issues.dlang.org/show_bug.cgi?id=21794
2 /*
3 TEST_OUTPUT:
4 ---
6 0u
7 0L
8 0LU
9 0.0F
10 0.0
11 0.0L
12 ---
15 bool fun(void* p) {
16 const x = cast(ulong)p;
17 return 1;
20 static assert(fun(null));
22 T fun2(T)(void* p) {
23 const x = cast(T)p;
24 return x;
27 // These were an error before, they were returning a NullExp instead of IntegerExp/RealExp
29 static assert(fun2!int(null) == 0);
30 static assert(fun2!uint(null) == 0);
31 static assert(fun2!long(null) == 0);
32 static assert(fun2!ulong(null) == 0);
33 static assert(fun2!float(null) == 0);
34 static assert(fun2!double(null) == 0);
35 static assert(fun2!real(null) == 0);
37 // These were printing 'null' instead of the corresponding number
39 const i = cast(int)null;
40 const ui = cast(uint)null;
41 const l = cast(long)null;
42 const ul = cast(ulong)null;
43 const f = cast(float)null;
44 const d = cast(double)null;
45 const r = cast(real)null;
46 pragma(msg, i);
47 pragma(msg, ui);
48 pragma(msg, l);
49 pragma(msg, ul);
50 pragma(msg, f);
51 pragma(msg, d);
52 pragma(msg, r);