Bug 21772 – [REG2.069] Consecutive different-signed double.nans in an array literal take the sign of the previous nan (same for float and real)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-27T08:57:18Z
Last change time
2023-01-13T22:21:27Z
Keywords
backend, pull, wrong-code
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2021-03-27T08:57:18Z
Demonstration below. Bug does not appear in LDC. --- void main() { import std.stdio : writeln; import std.math : isIdentical; double[] a = [-double.nan, double.nan, double.nan, 1.0, double.nan, -double.nan]; writeln(a); // Writes "[-nan, -nan, -nan, 1, nan, nan]" (Uh-oh!) assert(!isIdentical(a[0], a[1])); // Fails of course. } ---
Comment #1 by n8sh.secondary — 2021-03-27T09:02:21Z
If you go all the way back to 2.068.2 `std.stdio.writeln` doesn't print the sign of nan by default but you can verify with `std.math.signbit` that the nans have different signs.
Comment #2 by dlang-bot — 2022-12-20T21:21:37Z
@WalterBright created dlang/dmd pull request #14727 "fix Issue 21772 - [REG2.069] Consecutive different-signed double.nans…" fixing this issue: - fix Issue 21772 - [REG2.069] Consecutive different-signed double.nans in an array literal take the sign of the previous nan (same for float and real) https://github.com/dlang/dmd/pull/14727
Comment #3 by dlang-bot — 2023-01-13T22:21:27Z
dlang/dmd pull request #14727 "fix Issue 21772 - [REG2.069] Consecutive different-signed double.nans…" was merged into master: - ded5508a8c1532f0522bf171277018ef7f64a44d by Walter Bright: fix Issue 21772 - [REG2.069] Consecutive different-signed double.nans in an array literal take the sign of the previous nan (same for float and real) https://github.com/dlang/dmd/pull/14727