Bug 21325 – Flags not set for ?: evaluation with floating point operands

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-10-18T08:36:07Z
Last change time
2020-12-21T22:18:51Z
Keywords
backend, pull, wrong-code
Assigned to
No Owner
Creator
thomas.bockman

Comments

Comment #0 by thomas.bockman — 2020-10-18T08:36:07Z
The program below should return 0. On Linux x86_64 it works properly with LDC or GDC, and even with DMD in debug mode. But, it fails and returns 1 with DMD -release -inline -O. (This was reduced from a multi-thousand line program.) //////////////////////////////////////////////// module app; real f(const real x) pure @safe nothrow @nogc { return (x != 0.0L)? x : real.nan; } int main() @safe { ulong x = 0uL; while(true) { const y = f(x); // should set y to real.nan if(y == y) return 1; // bad if(++x) return 0; // good } } ////////////////////////////////////////////////
Comment #1 by thomas.bockman — 2020-10-18T08:46:29Z
My example fails on 2.094.1 beta, but works on 2.093 so I am marking this as a regression.
Comment #2 by ibuclaw — 2020-10-18T15:29:44Z
-release is irrelevant in the issue, replacing `return 1` with `assert(0)` triggers with just -O -inline. Regression was caused by this commit https://github.com/dlang/dmd/pull/11682
Comment #3 by dlang-bot — 2020-11-09T04:19:44Z
@WalterBright created dlang/dmd pull request #11939 "fix Issue 21325 - Flags not set for ?: evaluation with floating point…" fixing this issue: - fix Issue 21325 - Flags not set for ?: evaluation with floating point operands https://github.com/dlang/dmd/pull/11939
Comment #4 by dlang-bot — 2020-11-15T00:39:08Z
dlang/dmd pull request #11939 "fix Issue 21325 - Flags not set for ?: evaluation with floating point…" was merged into master: - aea1dcb1c2205807456f7cb24d5e1372019e11c1 by Walter Bright: fix Issue 21325 - Flags not set for ?: evaluation with floating point operands https://github.com/dlang/dmd/pull/11939
Comment #5 by thomas.bockman — 2020-12-21T22:18:51Z
I can confirm that this works for me now with DMD Beta 2.095.0-beta.1, including in my original, pre-reduction program. Thanks!