[Issue 378] Assertion failure: '0' on line 216 in file 'init.c'

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 16 03:16:36 PDT 2006


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





------- Comment #2 from braddr at puremagic.com  2006-10-16 05:16 -------
Adding 'static' before Degree a eliminates the error.  A reduced test case that
shows the same behavior:

struct Ranged {
    float value, min, max, range;
}

void main() {
    Ranged a = {0f, 0f, 360f, 360f};
} 

Changing the line in main to "static Ranged ..." also removes the error.  Is
the original test case actually valid code?  Struct initializers, by spec, are
only allowed for static instances.  The syntax for default initialization for
structs is like this:

    struct X { int a; int b; int c; int d = 7; }

I'm not sure that it's possible to give struct's new default initializations
when typedef'ing them like this.  Walter?  Language lawyer?  For reference, the
typedef part of the spec is fairly anemic and only gives this one example:

    typedef int myint = 7;
    myint m;        // initialized to 7


-- 




More information about the Digitalmars-d-bugs mailing list