https://issues.dlang.org/show_bug.cgi?id=17654
--- Comment #2 from ag0ae...@gmail.com --- (In reply to Steven Schveighoffer from comment #1) > I actually think it's a design problem. assumeUTF is marked pure. The input > is ubyte and the output is char. This means the compiler can reasonably > assume the output is unrelated to the input and therefore unique. > > This is quite a pickle. We can't very well unmark it pure, and I think the > compiler logic is sound. I don't agree that the compiler logic is sound. The casts are valid. The compiler cannot assume that they don't occur. It even happens with classes (no cast needed): ---- class B { int x; } class C : B {} B toB(C c) pure { return c; } void main() { C c = new C; c.x = 1; immutable B b = toB(c); /* should be rejected */ assert(b.x == 1); /* passes */ c.x = 2; assert(b.x == 1); /* fails */ } ---- --