Thread overview
[Issue 378] New: Assertion failure: '0' on line 216 in file 'init.c'
Sep 27, 2006
d-bugmail
Sep 29, 2006
Thomas Kuehne
Oct 16, 2006
d-bugmail
Oct 16, 2006
d-bugmail
Oct 16, 2006
d-bugmail
Oct 24, 2006
d-bugmail
Nov 25, 2006
d-bugmail
September 27, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378

           Summary: Assertion failure: '0' on line 216 in file 'init.c'
           Product: D
           Version: 0.167
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: h3r3tic@mat.uni.torun.pl


struct Ranged(T){
        T value, min, max, range;
}

typedef Ranged!(float) Degree = {0f, 0f, 360f, 360f};


void main() {
        Degree a;
}


-- 

September 29, 2006
d-bugmail@puremagic.com schrieb am 2006-09-27:
> http://d.puremagic.com/issues/show_bug.cgi?id=378

> struct Ranged(T){
>         T value, min, max, range;
> }
>
> typedef Ranged!(float) Degree = {0f, 0f, 360f, 360f};
>
>
> void main() {
>         Degree a;
> }

Added to DStress as http://dstress.kuehne.cn/run/t/typedef_20_A.d http://dstress.kuehne.cn/run/t/typedef_20_B.d

Thomas


October 16, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378





------- Comment #2 from braddr@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


-- 

October 16, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378





------- Comment #3 from braddr@puremagic.com  2006-10-16 05:52 -------
With dmd 167 it reported this:
  378-a.d(8): variable foo.main.a is not a static and cannot have static
initializer

If I had to guess, I'd say the problem is related to the stack variable initialization changes in 168.


-- 

October 16, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378


h3r3tic@mat.uni.torun.pl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code




------- Comment #4 from h3r3tic@mat.uni.torun.pl  2006-10-16 07:41 -------
You're probably right... Too bad, as default initialization for non-static struct instances or struct ctors would be very handy. Sorry for the misinformation.

I guess I'll let the bug stay because of the assertion...


-- 

October 24, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378


braddr@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wbaxter@gmail.com




------- Comment #5 from braddr@puremagic.com  2006-10-24 14:10 -------
*** Bug 452 has been marked as a duplicate of this bug. ***


-- 

November 25, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=378


bugzilla@digitalmars.com changed:

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




------- Comment #6 from bugzilla@digitalmars.com  2006-11-25 03:51 -------
Fixed DMD 0.175


--