Bug 24665 – Static array cast can be an unsafe lvalue

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-07-16T18:39:35Z
Last change time
2024-12-13T19:36:28Z
Keywords
safe
Assigned to
No Owner
Creator
Nick Treleaven
Moved to GitHub: dmd#18257 →

Comments

Comment #0 by nick — 2024-07-16T18:39:35Z
Both the cast assignments below corrupt the address of the Object reference in c[0]. They should be rejected in @safe code. void main() @safe { Object[1] c; (cast(size_t[1]) c) = 2; //! (cast(size_t[1]) c)[0] = 2; //! } Note that when used as an rvalue, the casts are OK.
Comment #1 by robert.schadek — 2024-12-13T19:36:28Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18257 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB