www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20903] New: seg fault on long signed divide overflow

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

          Issue ID: 20903
           Summary: seg fault on long signed divide overflow
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

The following:

  long test() {
    long r = 0x8000_0000_0000_0000L;
    long x = -1L;
    return r / x; // crashes here
  }

  import core.stdc.stdio;

  int main() {
    printf("result: %llx\n", test());
    return 0;
  }

crashes when compiled with -O on 64 bit code.

--
Jun 07 2020