[Issue 7280] New: Can't get address of array `.length` or `.ptr` properties

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 12 09:06:58 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7280

           Summary: Can't get address of array `.length` or `.ptr`
                    properties
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis <verylonglogin.reg at gmail.com> 2012-01-12 20:06:56 MSK ---
---
void f() {
    void[] arr;
    size_t* _length = &arr.length; // Error: arr.length is not an lvalue
    void** _ptr = &arr.ptr;        // Error: cast(void*)arr is not an lvalue
}
---
What is the case not to behave like a struct of two elements?

Workaround:
---
size_t* arrayLengthRef(T)(ref T[] arr) {
    return (cast(size_t*)&arr);
}

T** arrayPtrRef(T)(ref T[] arr) {
    return (cast(T**)&arr) + 1;
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list