[Issue 2544] implicit const casting rules allow violations of const-safety
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 1 18:31:03 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2544
------- Comment #1 from lat7h at virginia.edu 2009-01-01 20:31 -------
I included an unnecessary level of indirection before. A simpler example:
----
const(int)[] answers = [42]; // create const data
int[][] unconsted = [[]]; // create mutable data
const(int)[][] unsafe = unconsted; // and a partially-constant view of it
unsafe[0] = answers; // place const data in the const view
unconsted[0][0] = 43; // change const data
----
Thus, while "const(T)[] = T[]" is safe, "const(T)[][] = T[][]" is not; only a
single level of implicit indirection in the cast preserves constness.
--
More information about the Digitalmars-d-bugs
mailing list