www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11106] New: Chaos on struct with multidimentional static array initialization from its element

http://d.puremagic.com/issues/show_bug.cgi?id=11106

           Summary: Chaos on struct with multidimentional static array
                    initialization from its element
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid, rejects-valid, 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-09-23
10:16:21 MSD ---
---
struct S
{ int[2][1] a21; }

void main()
{
    int[2][1] a21 = [1, 2]; // ok
    static assert(!__traits(compiles, a21 = [1])); // ok

    static assert(!__traits(compiles, { static S ss = { a21: [1]}; })); //
assert fails, creates a21 = [[1, 0]]
    static S ss = { a21: [1, 2]}; // Error: array initializer has 2 elements,
but array length is 1
    S s = S([1, 2]); // [Issue 11105] Error: cannot implicitly convert
expression ([1, 2]) of type int[] to int[2u][1u]
}
---

Some indices ICEs the compiler:
---
struct S
{ int[2][2] a22; }

static S ss = { a22: [1]}; // Assertion failure: 'sz == vsz || sz * dim <= vsz'
on line 144 in file 'todt.c'
---

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