[Issue 12365] New: Assigning 1D array to 2D array should require cast

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 14 16:40:57 PDT 2014


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

           Summary: Assigning 1D array to 2D array should require cast
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: growlercab at gmail.com


--- Comment #0 from growlercab at gmail.com 2014-03-14 16:40:54 PDT ---
The code in Ex.1 compiles and runs fine but I think it needs a cast:
---
// Ex.1
void main()
{
    int[] a=[1,2,3,4];
    int[2][2] b = a;
}
---


Array assignment in Ex.2 only works with a cast:
---
// Ex.2
void main()
{
    int[] a=[1,2,3,4];
    int[2][2] b;

    b = a; // Compile time error

    cast(int[4])b = a; // works ok
}
---

I think it should be consistent, preferably with a cast.


Thanks,
ed

-- 
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