www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11470] New: Static array of `float`s is implicitly initializable from array of `double`s

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg 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: -------
Nov 07 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11470


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-12-02 21:19:56 PST ---
*** This issue has been marked as a duplicate of issue 11426 ***

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