[Issue 19754] cast() sometimes yields lvalue, sometimes yields rvalue
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 30 17:59:24 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19754
--- Comment #14 from ag0aep6g <ag0aep6g at gmail.com> ---
(In reply to kinke from comment #13)
> It does yield an lvalue now with v2.087, but a wrong one (temporary, I
> guess):
>
> void main()
> {
> const x = 0;
> const p = &x;
> (cast() x) = 5; // wrongly const-folded to 0 = 5
> assert(*p == 5); // fails, still 0
> }
That code is invalid. Mutating x has undefined behavior.
--
More information about the Digitalmars-d-bugs
mailing list