Bug 24445 – Type cast dropping const should not be an lvalue

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-03-20T17:23:44Z
Last change time
2024-12-13T19:33:58Z
Assigned to
No Owner
Creator
Nick Treleaven
Moved to GitHub: dmd#20419 →

Comments

Comment #0 by nick — 2024-03-20T17:23:44Z
The docs say the result is an lvalue for: > cast(U) expressions applied to lvalues of type T when T* is implicitly convertible to U*; https://dlang.org/spec/expression.html#.define-lvalue const int* does not implicitly convert to int*, yet: void main() { const int i; cast(int) i = 2; assert(i == 0); // passes } The cast is making a hidden copy, which should be an rvalue. So the assignment should error.
Comment #1 by robert.schadek — 2024-12-13T19:33:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20419 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB