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