[Issue 17034] New: DMD 32 bit PIC wrong code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Dec 26 02:24:16 PST 2016


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

--


More information about the Digitalmars-d-bugs mailing list