[Issue 640] New: Strage error messages around structInstance.init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 3 09:23:41 PST 2006


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

           Summary: Strage error messages around structInstance.init
           Product: D
           Version: 0.176
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: kinaba at is.s.u-tokyo.ac.jp


// 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;
}


-- 




More information about the Digitalmars-d-bugs mailing list