[Issue 4967] member default initializers not working in static struct initializers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 29 00:55:06 PDT 2012


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|{ } struct literals not     |member default initializers
                   |documented, and not working |not working in static
                   |                            |struct initializers


--- Comment #4 from Don <clugdbug at yahoo.com.au> 2012-05-29 00:56:54 PDT ---
They are documented in struct.html, "Static Initialization of Structs"

The bug is that default initializers are ignored for members which aren't in
the struct static initializer. When this bug was originally filed, they got
garbage.
Now they use the default initializer for the type, but they should use the
member initializer, if one is present.

Barely tested patch, in init.c (350), StructInitializer::toExpression():

            if (!(*elements)[i])
               // Default initialize
+                if (vd->init)
+                    (*elements)[i] = vd->init->toExpression();
+                else                
                    (*elements)[i] = vd->type->defaultInit();

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