January 12, 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@puremagic.com
        ReportedBy: verylonglogin.reg@gmail.com


--- Comment #0 from Denis <verylonglogin.reg@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: -------
January 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7280


Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |schveiguy@yahoo.com
         Resolution|                            |WONTFIX


--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2012-01-12 10:17:01 PST ---
arr.length is a read/write property.  Writing length is not a simple field set,
it calls a runtime function.
arr.ptr is a read only property.

Setting these must be done in tandem, and is done via the slicing interface or via the length set operation.  You can circumvent as you say, but it should not be easy, since it is very dangerous.

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