[Issue 6189] New: register content destroyed in function prolog

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 21 05:56:48 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6189

           Summary: register content destroyed in function prolog
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dawg at dawgfoto.de


--- Comment #0 from dawg at dawgfoto.de 2011-06-21 05:52:01 PDT ---
struct FPoint {
  float x, y;
}

void constructBezier(FPoint p0, FPoint p1, FPoint p2, ref FPoint[3] quad) {
  quad[0] = p0;
  quad[1] = FPoint(p1.x, p1.y);
  quad[$-1] = p2;
}

void main() {
  auto p0 = FPoint(0, 0);
  auto p1 = FPoint(1, 1);
  auto p2 = FPoint(2, 2);

  // avoid inline of call
  FPoint[3] quad;
  auto f = &constructBezier;
  f(p0, p1, p2, quad);

  assert(quad == [p0, p1, p2]);
}

---

This code will fail if compiled with optimization.
The issue is that quad variable is assigned to a register during the function.
In the function prolog quad is move from it's parameter register to the target
register while another parameter still resides in that register.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list