[Issue 18758] New: RVO ignores asm writing to return value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 13 07:27:16 UTC 2018


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

          Issue ID: 18758
           Summary: RVO ignores asm writing to return value
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

This code assert for both x86 and x64:


struct S { int x; int y; int z; }

S foo()
{
        S s;
        asm
        {
                mov EAX, 42;
                mov [s], EAX;
        }
        return s;
}

void main()
{
        S s;
        s = foo();
        assert(s.x == 42);
}


A workaround seems to be to assign the return value to a temporary first, but
this seems brittle when optimizations might remove the unnecessary copy.

--


More information about the Digitalmars-d-bugs mailing list