digitalmars.D.bugs - [Issue 4791] New: Assigning a static array to itself should be allowed
- d-bugmail puremagic.com (28/28) Sep 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4791
- d-bugmail puremagic.com (14/14) Sep 03 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4791
- d-bugmail puremagic.com (6/6) Sep 03 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4791
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 puremagic.com ReportedBy: dsimcha yahoo.com 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: -------
Sep 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4791 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc The only correct syntax to write that code is this, see bug 3971 void main() { int[2] foo; foo[] = foo[]; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4791 Yes, and this is a nightmare for generic code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2010