digitalmars.D.bugs - [Issue 9429] New: Unclear runtime error in array assignment of misaligned types.
- d-bugmail puremagic.com (36/36) Jan 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9429
- d-bugmail puremagic.com (16/16) Jan 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9429
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 puremagic.com ReportedBy: estewh gmail.com 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: -------
Jan 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9429 Just some additional info: The error itself *is* correct, I'm only reporting that the message is misleading...if possible it would be nice to see it at compile time. I tested on the following configurations: OS: fedora 18 x86_64. Compiler: DMD 2.061 64 bit Binary produced: elf64-x86-64 OS: Windows 7 64 bit Compiler: DMD 2.061 32 bit Binary produced: 32 bit The messages are virtually the same on both systems. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2013