www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2485] New: non-static initialization of struct using static initializer syntax generates wrong code

reply d-bugmail puremagic.com writes:
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)


-- 
Dec 02 2008
parent d-bugmail puremagic.com writes:
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: -------
Oct 07 2010