[Issue 6610] New: opAssign when copy-ing array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 6 02:47:17 PDT 2011
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 at puremagic.com
ReportedBy: luka8088 at owave.net
--- Comment #0 from luka8088 <luka8088 at owave.net> 2011-09-06 02:47:02 PDT ---
/*
* 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: -------
More information about the Digitalmars-d-bugs
mailing list