[Issue 4791] New: Assigning a static array to itself should be allowed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 2 21:49:14 PDT 2010


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

           Summary: Assigning a static array to itself should be allowed
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2010-09-02 21:48:58 PDT ---
void main() {
    int[2] foo;
    foo = foo;
}

object.Exception: overlapping array copy

This is a ridiculous limitation and is bugs waiting to happen.  (For example,
Bug 4789.)  Even if this requires a simple runtime check before calling
memcpy() or whatever, IMHO it's worth it because the cost of a single pointer
comparison is negligible in almost all cases and for tiny static arrays (where
it might not be negligible) the compiler could just generate regular assignment
instructions that are safe for the overlapping/identical case instead of using
something like memcpy().

-- 
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