[Issue 8410] New: Static initializers for fixed size arrays too

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 22 06:22:18 PDT 2012


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

           Summary: Static initializers for fixed size arrays too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-07-22 06:22:17 PDT ---
struct Foo { int[15] x; string s; }
void main() {
    Foo[5] a1 = Foo([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "hello"); // OK
    Foo f = { s: "hello" }; // OK (not static)
    Foo[5] a2 = { s: "hello" }; // error
}


DMD 2.060alpha gives:

temp.d(5): Error: a struct is not a valid initializer for a Foo[5u]
temp.d(5): Error: variable temp.main.a2 is not a static and cannot have static
initializer


I'd like the third syntax too to work, because it saves me to specify all the
struct fields, like the x array.

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


More information about the Digitalmars-d-bugs mailing list