Bug 378 – Assertion failure: '0' on line 216 in file 'init.c'

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-27T12:06:00Z
Last change time
2014-02-15T13:21:15Z
Keywords
ice-on-invalid-code
Assigned to
bugzilla
Creator
h3r3tic

Comments

Comment #0 by h3r3tic — 2006-09-27T12:06:44Z
struct Ranged(T){ T value, min, max, range; } typedef Ranged!(float) Degree = {0f, 0f, 360f, 360f}; void main() { Degree a; }
Comment #1 by thomas-dloop — 2006-09-29T02:05:36Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] 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 -----BEGIN PGP SIGNATURE----- iD8DBQFFHMd8LK5blCcjpWoRAoQ/AJ9Gv/sORwzEnqpR2YiKjmxrigh/YQCfVSeD BQVrBzlnFXjwU41CBz1QUB0= =nbYK -----END PGP SIGNATURE-----
Comment #2 by braddr — 2006-10-16T05:16:36Z
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
Comment #3 by braddr — 2006-10-16T05:52:58Z
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.
Comment #4 by h3r3tic — 2006-10-16T07:41:58Z
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...
Comment #5 by braddr — 2006-10-24T14:10:17Z
*** Bug 452 has been marked as a duplicate of this bug. ***
Comment #6 by bugzilla — 2006-11-25T03:51:11Z
Fixed DMD 0.175