digitalmars.D.bugs - [Issue 24445] New: Type cast dropping const should not be an lvalue
- d-bugmail puremagic.com (25/26) Mar 20 https://issues.dlang.org/show_bug.cgi?id=24445
https://issues.dlang.org/show_bug.cgi?id=24445 Issue ID: 24445 Summary: Type cast dropping const should not be an lvalue Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: nick geany.org 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. --
Mar 20