[Issue 11470] New: Static array of `float`s is implicitly initializable from array of `double`s

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 7 11:14:51 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11470

           Summary: Static array of `float`s is implicitly initializable
                    from array of `double`s
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid, wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-11-07 22:14:50 MSK ---
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. )

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


More information about the Digitalmars-d-bugs mailing list