| 1 |
// https://issues.dlang.org/show_bug.cgi?id=21794 |
| 2 |
/* |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
0 |
| 6 |
0u |
| 7 |
0L |
| 8 |
0LU |
| 9 |
0.0F |
| 10 |
0.0 |
| 11 |
0.0L |
| 12 |
--- |
| 13 |
*/ |
| 14 |
|
| 15 |
bool fun(void* p) { |
| 16 |
const x = cast(ulong)p; |
| 17 |
return 1; |
| 18 |
} |
| 19 |
|
| 20 |
static assert(fun(null)); |
| 21 |
|
| 22 |
T fun2(T)(void* p) { |
| 23 |
const x = cast(T)p; |
| 24 |
return x; |
| 25 |
} |
| 26 |
|
| 27 |
// These were an error before, they were returning a NullExp instead of IntegerExp/RealExp |
| 28 |
|
| 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); |
| 36 |
|
| 37 |
// These were printing 'null' instead of the corresponding number |
| 38 |
|
| 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); |