[Issue 14452] [REG2.067] Floating point invalid operation when returning a structure containing a float field

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 22 07:48:39 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14452

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
This is a side effect of
https://github.com/D-Programming-Language/dmd/pull/3885 .

Currently, dmd backend uses FLD and FSTP x87 instructions to initialize a float
variable with NaN. It could raise Invalid Floating Point exception.

int main()
{
    import std.math : FloatingPointControl;
    FloatingPointControl fpCtrl; 
    fpCtrl.enableExceptions(FloatingPointControl.severeExceptions);

    float x;        // raises Invalid FP Op exception

    struct S { float f; }
    auto s = S();   // ditto
}

B the pull 3885, a struct constructor call had changed to a struct literal
expression with constructor member function call. When the object image is
initialized with the default values before ctor call, the NaN setting will
raise exception.

It's a behavior change in 2.067, but I'm not sure it's a wrong-code bug.

--


More information about the Digitalmars-d-bugs mailing list