digitalmars.D.bugs - [Issue 17034] New: DMD 32 bit PIC wrong code
- via Digitalmars-d-bugs (40/40) Dec 26 2016 https://issues.dlang.org/show_bug.cgi?id=17034
https://issues.dlang.org/show_bug.cgi?id=17034 Issue ID: 17034 Summary: DMD 32 bit PIC wrong code Product: D Version: D2 Hardware: x86 OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: safety0ff.bugz gmail.com Created attachment 1628 --> https://issues.dlang.org/attachment.cgi?id=1628&action=edit 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. --
Dec 26 2016