[Issue 9425] New: Static struct initializer fails to init array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 29 09:14:42 PST 2013


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

           Summary: Static struct initializer fails to init array
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: SebastianGraf at t-online.de


--- Comment #0 from Sebastian Graf <SebastianGraf at t-online.de> 2013-01-29 09:14:41 PST ---
I found this when fixing a bug in ldc on Win8 x64. I'm pretty sure all
platforms are concerned, because the linux CI server complained for the same
reason.

import std.conv;

struct S { int array[4]; }

void main() 
{ 
    int array[4] = 67; // array = [67, 67, 67, 67]
    static S s = S(67); // s.array = [67, 0, 0, 0]
    assert(array == s.array, "s.array (actual): " ~ to!string(s.array) ~ ",
array (expected): " ~ to!string(array));
}

When initializing array in S' initializer, only the first element of the array
takes the value, the others are zero'd. I expected the array to be filled with
the value. 
Note that this is the case when you don't declare s as static, so I assume it
is a bug.

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