On Friday, 5 January 2018 at 18:13:11 UTC, H. S. Teoh wrote:
On Fri, Jan 05, 2018 at 05:50:34PM +, jmh530 via
Digitalmars-d-learn wrote:
Be careful with that:
class C { int x; }
immutable C c = new C(5);
auto i = c.x;
C y = cast(C) c;
y.x = 10;
On Fri, Jan 05, 2018 at 05:50:34PM +, jmh530 via Digitalmars-d-learn wrote:
> On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer wrote:
> >
> > Yes, this is undefined behavior.
> >
> > https://dlang.org/spec/const3.html#removing_with_cast
> >
> > The compiler assumes x is going
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer
wrote:
Yes, this is undefined behavior.
https://dlang.org/spec/const3.html#removing_with_cast
The compiler assumes x is going to be 5 forever, so instead of
loading the value at that address, it just loads 5 into a
register (or
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer
wrote:
Yes, this is undefined behavior.
https://dlang.org/spec/const3.html#removing_with_cast
The compiler assumes x is going to be 5 forever, so instead of
loading the value at that address, it just loads 5 into a
register (or
On Friday, January 05, 2018 04:16:48 Adam D. Ruppe via Digitalmars-d-learn
wrote:
> On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer
>
> wrote:
> > The compiler assumes x is going to be 5 forever, so instead of
> > loading the value at that address, it just loads 5 into a
> > regist
On Thursday, January 04, 2018 23:10:54 Steven Schveighoffer via Digitalmars-
d-learn wrote:
> On 1/4/18 10:58 PM, jmh530 wrote:
> > I'm trying to understand the consequences of casting away immutable from
> > a pointer. The code below has some weird things going on like the
> > pointers still point
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer
wrote:
The compiler assumes x is going to be 5 forever, so instead of
loading the value at that address, it just loads 5 into a
register (or maybe it just folds x == 5 into true).
I was curious what dmd did, and the disassembly in
On 1/4/18 10:58 PM, jmh530 wrote:
I'm trying to understand the consequences of casting away immutable from
a pointer. The code below has some weird things going on like the
pointers still point to the correct address but when you dereference
them they don't point to the correct value anymore.
I'm trying to understand the consequences of casting away
immutable from a pointer. The code below has some weird things
going on like the pointers still point to the correct address but
when you dereference them they don't point to the correct value
anymore.
Should I just assume this is unde