digitalmars.D.bugs - [Issue 6610] New: opAssign when copy-ing array
- d-bugmail puremagic.com (46/46) Sep 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6610
http://d.puremagic.com/issues/show_bug.cgi?id=6610
Summary: opAssign when copy-ing array
Product: D
Version: unspecified
Platform: Other
OS/Version: All
Status: NEW
Severity: minor
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: luka8088 owave.net
/*
* As discussed on #d freenode on 2011-09-06
* Should this work ?
*
*/
import std.stdio;
struct s {
int a;
int b;
int c;
void opAssign (s value) {
// Should opAssign be call for each array member ?
(&this)[0..1] = (&value)[0..1];
// causes infinite loop (as it should)
// this = value;
this.c = 4;
}
}
void main () {
writeln("start");
s s1;
s1.a = 1;
s1.b = 2;
s1.c = 3;
s s2;
s2 = s1;
writeln(s1.a, " ", s1.b, " ", s1.c); // 1 2 3
writeln(s2.a, " ", s2.b, " ", s2.c); // 1 2 4
writeln("end");
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 06 2011








d-bugmail puremagic.com