diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2023-01-04 15:18:17 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-01-05 02:22:30 -0700 |
| commit | e0fb4c29cb618fe912c82fed06bb305db14606d8 (patch) | |
| tree | 8443bb64aaf65db00dc760c659c93754031fd824 /test/behavior | |
| parent | b89158d6fd7ce0960b3f8085368ae102b48747d0 (diff) | |
| download | zig-e0fb4c29cb618fe912c82fed06bb305db14606d8.tar.gz zig-e0fb4c29cb618fe912c82fed06bb305db14606d8.zip | |
llvm codegen: fix f16,f32,f64 nan bitcasts
@bitCast from integer NaN representation to float NaN resulted in
changed bits in float. This only happened with signaled NaN.
- added test for signaled NaN
- added tests for quiet NaN (for completeness)
closes #14198
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/bugs/14198.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/behavior/bugs/14198.zig b/test/behavior/bugs/14198.zig new file mode 100644 index 0000000000..92a33f4589 --- /dev/null +++ b/test/behavior/bugs/14198.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const math = std.math; +const mem = std.mem; +const testing = std.testing; + +test "nan memory equality" { + // signaled + try testing.expect(mem.eql(u8, mem.asBytes(&math.nan_u16), mem.asBytes(&math.nan_f16))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.nan_u32), mem.asBytes(&math.nan_f32))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.nan_u64), mem.asBytes(&math.nan_f64))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.nan_u128), mem.asBytes(&math.nan_f128))); + + // quiet + try testing.expect(mem.eql(u8, mem.asBytes(&math.qnan_u16), mem.asBytes(&math.qnan_f16))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.qnan_u32), mem.asBytes(&math.qnan_f32))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.qnan_u64), mem.asBytes(&math.qnan_f64))); + try testing.expect(mem.eql(u8, mem.asBytes(&math.qnan_u128), mem.asBytes(&math.qnan_f128))); +} |
