Bug 11470 – Static array of `float`s is implicitly initializable from array of `double`s

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-07T11:14:00Z
Last change time
2013-12-02T21:19:56Z
Keywords
accepts-invalid, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-11-07T11:14:50Z
It is rewritten as for `cast(float[])`: --- void main() { double[3] d3; float[3] f3 = d3; // or `= new double[3]` } --- And correctly fails in runtime with: --- object.Error: lengths don't match for array copy, 3 = 6 ---- This was discovered from Issue 9429 an is major as e.g. this will compile and fail in RT with same error as above: --- float[3] arr = [1.0, 2.0, 3.0].dup; --- P.S. Want to laugh? There is Issue 6489. Looks like its author applied some magic to force dmd partially accept what he wants. As always magic worked bed. Thus we all prefer science now. )
Comment #1 by k.hara.pg — 2013-12-02T21:19:56Z
*** This issue has been marked as a duplicate of issue 11426 ***