D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20903 - seg fault on long signed divide overflow
Summary: seg fault on long signed divide overflow
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 major
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2020-06-07 09:27 UTC by Walter Bright
Modified: 2020-06-07 11:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2020-06-07 09:27:12 UTC
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.
Comment 1 Dlang Bot 2020-06-07 09:35:28 UTC
@WalterBright created dlang/dmd pull request #11244 "fix Issue 20903 - seg fault on long signed divide overflow" fixing this issue:

- fix Issue 20903 - seg fault on long signed divide overflow

https://github.com/dlang/dmd/pull/11244
Comment 2 Dlang Bot 2020-06-07 11:37:47 UTC
dlang/dmd pull request #11244 "fix Issue 20903 - seg fault on long signed divide overflow" was merged into master:

- 11c846737fc38474efdcaec3a9211babd43fc8a6 by Walter Bright:
  fix Issue 20903 - seg fault on long signed divide overflow

https://github.com/dlang/dmd/pull/11244