aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/fmt/nan64.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib9/fmt/nan64.c')
-rw-r--r--src/lib9/fmt/nan64.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c
index 3a1f2111..7d719157 100644
--- a/src/lib9/fmt/nan64.c
+++ b/src/lib9/fmt/nan64.c
@@ -26,11 +26,18 @@ __NaN(void)
int
__isNaN(double d)
{
+ /*
+ * Used to just say x = *(uvlong*)&d,
+ * but gcc miscompiles that!
+ */
+ union {
+ uvlong i;
+ double f;
+ } u;
uvlong x;
- double *p;
-
- p = &d;
- x = *(uvlong*)p;
+
+ u.f = d;
+ x = u.i;
/* IEEE 754: exponent bits 0x7FF and non-zero mantissa */
return (x&uvinf) == uvinf && (x&~uvneginf) != 0;
}