Test code:
void main() {
import std.stdio;
union X { int x; float y; }
X x;
x.x = -1;
writeln(x.y);
}
This should print "nan" but prints "-nan".
Comment #1 by iamthewilsonator — 2019-10-19T21:23:19Z
This is a phobos bug, not a dmd one.
Comment #2 by dlang-bugzilla — 2019-10-20T15:10:32Z
////////// test.c //////////
#include <stdio.h>
union X { int x; float y; };
int main()
{
union X x;
x.x = -1;
printf("%f\n", x.y);
return 0;
}
////////////////////////////
This also prints -nan.
What's the bug?
Comment #3 by bugzilla — 2019-10-20T17:26:49Z
Maybe it's no bug? IMHO the answer depends if D distinguishes between -nan and nan or not.