www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20278] New: ICE: calling std.math.sqrt with int cast to double

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

          Issue ID: 20278
           Summary: ICE: calling std.math.sqrt with int cast to double
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

Code:
------
struct S {
        int x,y;
        double f() {
                import std.math : sqrt;
                return sqrt(cast(double)x*x + y);
        }
}
------

Compiler output:
------
dmd: /usr/src/d/dmd/src/dmd/backend/cgcod.d:2489: Assertion
`cast(int)(*e).Ecomsub <= cast(int)(*e).Ecount' failed.
Aborted
------

Expected behaviour: the compiler should either emit an error indicating why the
code doesn't compile, or else compile the code successfully. It should not
crash with an assertion.

Submitting this as critical because it's an ICE.

--
Oct 07 2019