| 1 |
/* |
| 2 |
FIXME: DMD host compilers < 2.073 with faulty optimization |
| 3 |
lead to unfortunate test failures, see |
| 4 |
https://github.com/dlang/dmd/pull/6831#issuecomment-304495842. |
| 5 |
|
| 6 |
DISABLED: win32 win64 linux osx freebsd openbsd |
| 7 |
*/ |
| 8 |
|
| 9 |
/* |
| 10 |
TEST_OUTPUT: |
| 11 |
--- |
| 12 |
fail_compilation/impconv.d(30): Error: function `impconv.foo_float(float)` is not callable using argument types `(int)` |
| 13 |
fail_compilation/impconv.d(30): cannot pass argument `-2147483647` of type `int` to parameter `float` |
| 14 |
fail_compilation/impconv.d(31): Error: function `impconv.foo_float(float)` is not callable using argument types `(uint)` |
| 15 |
fail_compilation/impconv.d(31): cannot pass argument `4294967295u` of type `uint` to parameter `float` |
| 16 |
fail_compilation/impconv.d(34): Error: function `impconv.foo_double(double)` is not callable using argument types `(long)` |
| 17 |
fail_compilation/impconv.d(34): cannot pass argument `-9223372036854775807L` of type `long` to parameter `double` |
| 18 |
fail_compilation/impconv.d(35): Error: function `impconv.foo_double(double)` is not callable using argument types `(ulong)` |
| 19 |
fail_compilation/impconv.d(35): cannot pass argument `18446744073709551615LU` of type `ulong` to parameter `double` |
| 20 |
--- |
| 21 |
*/ |
| 22 |
|
| 23 |
void foo_float(float); |
| 24 |
void foo_double(double); |
| 25 |
void foo_real(real); |
| 26 |
|
| 27 |
void main() |
| 28 |
{ |
| 29 |
foo_float(1); // implicitly convertible to float |
| 30 |
foo_float(-int.max); // -(2^31 - 1) |
| 31 |
foo_float(uint.max); // 2^32 - 1 |
| 32 |
|
| 33 |
foo_double(int.max); // implicitly convertible to double |
| 34 |
foo_double(-long.max); // -(2^63 - 1) |
| 35 |
foo_double(ulong.max); // 2^64 - 1 |
| 36 |
|
| 37 |
foo_real(0xffff_ffff_ffffL); // 2^48 - 1, implicitly convertible to real |
| 38 |
static assert(__traits(compiles, foo_real(-long.max)) == (real.mant_dig >= 63)); |
| 39 |
static assert(__traits(compiles, foo_real(ulong.max)) == (real.mant_dig >= 64)); |
| 40 |
} |