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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 7 18:13:45 UTC 2019


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 at puremagic.com
          Reporter: hsteoh at 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.

--


More information about the Digitalmars-d-bugs mailing list