Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/dmd/root/longdouble.d
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,21 @@ nothrow @nogc pure:
T opCast(T)() const @trusted
{
static if (is(T == bool)) return mantissa != 0 || (exp_sign & 0x7fff) != 0;
else static if (is(T == byte)) return cast(T)ld_read(&this);
else static if (is(T == ubyte)) return cast(T)ld_read(&this);
else static if (is(T == short)) return cast(T)ld_read(&this);
else static if (is(T == ushort)) return cast(T)ld_read(&this);
else static if (is(T == int)) return cast(T)ld_read(&this);
else static if (is(T == uint)) return cast(T)ld_read(&this);
// Account for __c_[u]long
else static if (__traits(isIntegral,T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that on Win32, the host druntime's alias d_int32 = core.stdc.stdint.int32_t = core.stdc.config.cpp_long = __c_long (which is a magic enum). I've had a quick look into the VS 2017 stdint.h, and there int32_t is defined as int, not long, which would fix this as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing in favour of dlang/druntime#2302

{
static if (T.ziseof == 8)
{
static if (__traits(isUnsigned,T))
return cast(T)ld_readull(&this);
else
return cast(T)ld_readll(&this);
}
else
return cast(T)ld_read(&this);
}
else static if (is(T == float)) return cast(T)ld_read(&this);
else static if (is(T == double)) return cast(T)ld_read(&this);
else static if (is(T == long)) return ld_readll(&this);
else static if (is(T == ulong)) return ld_readull(&this);
else static if (is(T == real))
{
// convert to front end real if built with dmd
Expand Down