immutable/mutable aliasing

2014-07-03 Thread Jet via Digitalmars-d-learn
void foo(immutable int* x, int* y) { bar(*x); // bar(3) *y = 4; // undefined behavior bar(*x); // bar(??) } ... int i = 3; foo(cast(immutable)&i, &i); -- In the 2.065 version, I can compile. But that is not in the documentation.

Re: immutable/mutable aliasing

2014-07-03 Thread Jet via Digitalmars-d-learn
There, how to distinguish between const and immutable? thank you~:) /** "Const types are like immutable types, except that const forms a read-only view of data. Other aliases to that same data may change it at any time. " "Any data referenced by the const declaration cannot be changed from

Re: immutable/mutable aliasing

2014-07-03 Thread Jet via Digitalmars-d-learn
Thank you all. These answers are very detailed. I think I learned a lot.

Re: immutable/mutable aliasing

2014-07-03 Thread Jet via Digitalmars-d-learn
Awesome!!! Thank you so much!