Bug 17034 – DMD 32 bit PIC wrong code

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2016-12-26T10:24:00Z
Last change time
2017-01-16T23:26:03Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
safety0ff.bugz

Attachments

IDFilenameSummaryContent-TypeSize
1628pr4509bug.dfull details & codetext/x-dsrc371

Comments

Comment #0 by safety0ff.bugz — 2016-12-26T10:24:16Z
Created attachment 1628 full details & code For the following snippet from the attached code: struct S { long _value; void popFront() { _value >>>= 1; if (!_value) return; _value >>>= 1; // arbitrary code here } } Dmd emits the snippet (with -m32 -fPIC): 1: shrl 0x4(%edx) 2: rcrl (%edx) 3: mov 0x4(%edx),%edx 4: mov (%edx),%eax 5: or %eax,%edx 6: jne SomeAddress On line 3 Dmd overwrites the address of _value in EDX with the top 4 bytes of _value. Then on line 4, dmd loads the bottom 4 bytes of _value into EAX, but EDX no longer contains the address of _value, which leads to a segfault.
Comment #1 by safety0ff.bugz — 2016-12-26T23:22:16Z
Comment #2 by github-bugzilla — 2016-12-27T12:13:30Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d5ac4ac24e3546ca57c3f1b0b3602fff0e056418 Fix Issue 17034 - DMD 32 bit PIC wrong code https://github.com/dlang/dmd/commit/7ddfbaf4dea81e735084bbe3f53dbb9d850d1318 Merge pull request #6366 from WalterWaldron/fix17034 Fix Issue 17034 - DMD 32 bit PIC wrong code
Comment #3 by github-bugzilla — 2016-12-27T14:41:48Z
Commits pushed to scope at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d5ac4ac24e3546ca57c3f1b0b3602fff0e056418 Fix Issue 17034 - DMD 32 bit PIC wrong code https://github.com/dlang/dmd/commit/7ddfbaf4dea81e735084bbe3f53dbb9d850d1318 Merge pull request #6366 from WalterWaldron/fix17034
Comment #4 by github-bugzilla — 2017-01-16T23:26:03Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d5ac4ac24e3546ca57c3f1b0b3602fff0e056418 Fix Issue 17034 - DMD 32 bit PIC wrong code https://github.com/dlang/dmd/commit/7ddfbaf4dea81e735084bbe3f53dbb9d850d1318 Merge pull request #6366 from WalterWaldron/fix17034