[Issue 24665] New: Static array cast can be an unsafe lvalue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 16 18:39:35 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24665

          Issue ID: 24665
           Summary: Static array cast can be an unsafe lvalue
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: nick at geany.org

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.

--


More information about the Digitalmars-d-bugs mailing list