Thread overview
[Issue 2485] New: non-static initialization of struct using static initializer syntax generates wrong code
Dec 02, 2008
d-bugmail
Oct 07, 2010
Don
Jan 16, 2013
Don
December 02, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2485

           Summary: non-static initialization of struct using static
                    initializer syntax generates wrong code
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: tomas@famolsen.dk


The example from the spec added to document that static struct initializer syntax is allowed for non-static initialization doesn't do what it's supposed to with DMD.

I've produced a test case from it:

struct S {
    int a; int b; int c; int d = 7;
}
void test(int i) {
    S s = { 1, i };   // q.a = 1, q.b = i, q.c = 0, q.d = 7
    assert(s.a == 1);
    assert(s.b == i);
    assert(s.c == 0); // line 8
    assert(s.d == 7);
}
void main() {
    test(42);
}



$ dmd foo.d
$ ./foo
Error: AssertError Failure foo.d(8)


-- 

October 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2485


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-10-07 07:35:43 PDT ---
*** Issue 4552 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=2485


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2013-01-16 03:06:07 PST ---
Works now, I think it was the same as bug 2850.

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