January 31, 2013 [Issue 9429] New: Unclear runtime error in array assignment of misaligned types. | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from stewart <estewh@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: ------- |
January 31, 2013 [Issue 9429] Unclear runtime error in array assignment of misaligned types. | ||||
---|---|---|---|---|
| ||||
Posted in reply to stewart | http://d.puremagic.com/issues/show_bug.cgi?id=9429 --- Comment #1 from stewart <estewh@gmail.com> 2013-01-31 13:37:18 EST --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation