Bug 640 – Strage error messages around structInstance.init
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-12-03T11:23:00Z
Last change time
2014-02-15T13:19:19Z
Assigned to
bugzilla
Creator
kinaba
Comments
Comment #0 by kinaba — 2006-12-03T11:23:40Z
// credit goes to http://pc8.2ch.net/test/read.cgi/tech/1158013550/956
struct A { int a; }
void main() {
A x; // <-- test.d(3)
x = x.init;
}
----------------
test.d(3): Error: cannot implicitly convert expression (0) of type int to A
test.d(3): Error: cannot cast int to A
If x=x.init is commented out, or changed to x=A.init, the error disappears.
Even worse, a slightly modified version crashes dmd (access violation).
struct A { int a; }
void main() {
A x = {0};
x = x.init;
}