[Issue 9429] New: Unclear runtime error in array assignment of misaligned types.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 30 18:10:40 PST 2013


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

           Summary: Unclear runtime error in array assignment of
                    misaligned types.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody at puremagic.com
        ReportedBy: estewh at gmail.com


--- Comment #0 from stewart <estewh at gmail.com> 2013-01-31 13:10:37 EST ---
Given some bug infested code:

struct hackit {
    float[3] mine;
    void opAssign(E)(in E val) if(isArray!E) {
        mine = cast(const float[]))(val.dup);
    }
}
void main() {
    hackit v;
    float[3] v1 = cast(const float[])([1.0, 2.0, 3.0]);    // OK, no error
    v = [1.0, 2.0, 3.0]; // Fails at runtime with error message below
}

This error is thrown at runtime: "object.Error: lengths don't match for array
copy, 3 = 6"

It is correct, although misleading. Both arrays are length 3 and I believe this
should be:

object.Error: array cast misalignment

Swapping the types in the above code gives the error: "object.Error array cast
misalignement"

-- 
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