Union copy

"Luís "Luís
Wed Oct 23 07:49:07 PDT 2013


On Wednesday, 23 October 2013 at 14:43:07 UTC, Dicebot wrote:
> Can you check the value of `double` field in the copy origin 
> (immediately after initialization). It may have something to do 
> with floating arithmetic.

     // updated (b.v and writeln)
     void main()
     {
         Foo a;
         Foo b;
         b.v = null;
         b.i = 0x7ff7a502;
         writeln("b.d: ", b.d);
         copy(&a, &b);
         writef("a.i: %x\n", a.i);
         writeln("a.d: ", a.d);
     }

Linux:

     $ dmd -version=one test.d && ./test
     b.d: nan
     a.i: 7ff7a502
     a.d: nan

     $ dmd -version=two test.d && ./test
     b.d: nan
     a.i: 7fffa502
     a.d: nan

OS X:

     $ dmd -m32 -version=one test.d && ./test
     b.d: nan
     a.i: 7ff7a502
     a.d: nan

     $ dmd -m32 -version=two test.d && ./test
     b.d: nan
     a.i: 7ff7a502
     a.d: nan


More information about the Digitalmars-d mailing list