aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorLewis Gaul <lewis.gaul@gmail.com>2023-08-18 07:07:49 +0100
committerGitHub <noreply@github.com>2023-08-18 02:07:49 -0400
commit387b0ac4f1c54cb2f83792299aa628a316e17d88 (patch)
tree6b69315671946343c6171fe8cf3be451906b3d67 /src/codegen/c.zig
parent7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b (diff)
downloadzig-387b0ac4f1c54cb2f83792299aa628a316e17d88.tar.gz
zig-387b0ac4f1c54cb2f83792299aa628a316e17d88.zip
Make NaNs quiet by default and other NaN tidy-up (#16826)
* Generalise NaN handling and make std.math.nan() give quiet NaNs * Address uses of std.math.qnan_* and std.math.nan_* consts * Comment out failing test due to issues with signalling NaN * Fix issue in c_builtins.zig where we need qnan_u32
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 39b4165635..bea3c02985 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1087,7 +1087,7 @@ pub const DeclGen = struct {
// MSVC doesn't have a way to define a custom or signaling NaN value in a constant expression
// TODO: Re-enable this check, otherwise we're writing qnan bit patterns on msvc incorrectly
- // if (std.math.isNan(f128_val) and f128_val != std.math.qnan_f128)
+ // if (std.math.isNan(f128_val) and f128_val != std.math.nan(f128))
// return dg.fail("Only quiet nans are supported in global variable initializers", .{});
}
@@ -6704,13 +6704,13 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {
.Min => switch (scalar_ty.zigTypeTag(mod)) {
.Bool => Value.true,
.Int => try scalar_ty.maxIntScalar(mod, scalar_ty),
- .Float => try mod.floatValue(scalar_ty, std.math.nan_f128),
+ .Float => try mod.floatValue(scalar_ty, std.math.nan(f128)),
else => unreachable,
},
.Max => switch (scalar_ty.zigTypeTag(mod)) {
.Bool => Value.false,
.Int => try scalar_ty.minIntScalar(mod, scalar_ty),
- .Float => try mod.floatValue(scalar_ty, std.math.nan_f128),
+ .Float => try mod.floatValue(scalar_ty, std.math.nan(f128)),
else => unreachable,
},
}, .Initializer);