[Issue 9665] Structure constant members can not be initialized if have opAssign
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 9 08:02:09 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9665
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|nobody at puremagic.com |andrei at erdani.com
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-03-09 08:01:49 PST ---
This is unfixable problem, if I'm not mistaken.
Currently, compiler always considers opAssign operator overloading for all
field "assignment" in constructor.
struct S {
T field;
this(...) { field = xxx; } // If T has opAssign, it is called.
}
But for non-mutable field, opAssign invocation is not legal, because it may
break const correctness.
T* p;
struct T {
void opAssign(int n) { ...; p = &this; }
}
struct S {
immutable T field;
this(...) { field = 1; // invoke T.opAssign (currently not allowed)
/* now global p holds mutable pointer to immutable T object! */
}
}
I have no answer for this issue... So, assigned to Andrei.
--
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