MSVC: fix for failing tests due to strtod+hexadecimal literals

Kevin Brogan via digitalmars-d-ldc digitalmars-d-ldc at
Sun Mar 1 16:23:32 PST 2015

On Sunday, 1 March 2015 at 21:00:53 UTC, Johan Engelen wrote:
> Hi all,
>   MSVC's strtod does not deal correctly with hexadecimal 
> floating point literals, resulting a few unittests failing. For 
> example, the following program
> import std.math, std.stdio;
> void main() {
>     writeln(PI);
> }
> outputs "0" (zero), simply because std.math.PI is defined using 
> a hex literal and LDC2 compiled with MSVC cannot deal with that.
> See:
> I added
> #if _MSC_VER <= 1800
> VersionCondition::addPredefinedGlobalIdent("MSVC_STRTOD_NOHEXREALS");
> #endif
> to main.cpp, and then in std.math I defined PI and friends 
> using decimal floating point literals for 
> Is this a desired fix? (i.e. trying to make a better build with 
> MSVC while we wait for the new version)
> One positive effect of this change is that it un-hides some 
> other failing tests.
> thanks for comments,
>   Johan

Why use hex constants to begin with? Why not just use the 
floating point equivalent? The compiler will just substitute with 
the binary representation that is closest will it not?

More information about the digitalmars-d-ldc mailing list