www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11156] New: Refuse wrongly sized array assigned in C-style struct literal

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11156

           Summary: Refuse wrongly sized array assigned in C-style struct
                    literal
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



struct Foo {
    int[3] a;
}
void main() {
    Foo f1 =    {[10, 20]}; // No error.
    Foo f2 = Foo([10, 20]); // Line 6, Error.
}


DMD 2.064 alpha gives:

temp.d(6): Error: cannot implicitly convert expression ([10, 20]) of type int[]
to int[3]


I think D should accept both or refuse both. Probably it should refuse both.

See also issue 481

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11156


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



18:39:20 PDT ---
Also similar to Issue 3849.

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