aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig5
-rw-r--r--src/Value.zig2
2 files changed, 7 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 9e729a17ea..5982024d89 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -38137,6 +38137,11 @@ fn compareScalar(
const pt = sema.pt;
const coerced_lhs = try pt.getCoerced(lhs, ty);
const coerced_rhs = try pt.getCoerced(rhs, ty);
+
+ // Equality comparisons of signed zero and NaN need to use floating point semantics
+ if (coerced_lhs.isFloat(pt.zcu) or coerced_rhs.isFloat(pt.zcu))
+ return Value.compareHeteroSema(coerced_lhs, op, coerced_rhs, pt);
+
switch (op) {
.eq => return sema.valuesEqual(coerced_lhs, coerced_rhs, ty),
.neq => return !(try sema.valuesEqual(coerced_lhs, coerced_rhs, ty)),
diff --git a/src/Value.zig b/src/Value.zig
index be2c73c3e9..40e5331c4e 100644
--- a/src/Value.zig
+++ b/src/Value.zig
@@ -1132,6 +1132,8 @@ pub fn compareHeteroAdvanced(
else => {},
}
}
+
+ if (lhs.isNan(zcu) or rhs.isNan(zcu)) return op == .neq;
return (try orderAdvanced(lhs, rhs, strat, zcu, tid)).compare(op);
}