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

This code assert for both x86 and x64:

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

S foo()
        S s;
                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.


Reply via email to