[Issue 4745] New: Non-uniform handling of commas in static initialization of structs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 28 11:29:51 PDT 2010


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

           Summary: Non-uniform handling of commas in static
                    initialization of structs
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: stanislav.blinov at gmail.com


--- Comment #0 from Stanislav Blinov <stanislav.blinov at gmail.com> 2010-08-28 11:29:37 PDT ---
Compiler behaves differently for different cases when handling field
initializers for structs:

struct S1
{
    int a, b, c;

    static immutable S1 C1 = { 1 2 3 }; // no commas here, compiles
    static immutable S1 C2 = { 1, 2, 3 }; // compiles as well
}

int foo() { return 3; }

struct S2
{
    int a, b, c;

    static immutable S2 C1 = { foo() 2 3 }; // compiles (and works)
    static immutable S2 C2 = { foo() 2, 3 }; // compiles (and works)
    static immutable S2 C3 = { 2 foo() 3 }; // does not compile: comma expected
separating field initializers
}

Encountered this on 2.048 Windows (AMD64), 2.047 and 2.048 Linux (AMD64)

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