Thread overview
[Issue 640] New: Strage error messages around structInstance.init
Dec 03, 2006
d-bugmail
Dec 10, 2006
Thomas Kuehne
Apr 27, 2007
d-bugmail
Jul 13, 2007
d-bugmail
December 03, 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@digitalmars.com
        ReportedBy: kinaba@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;
}


-- 

December 10, 2006
d-bugmail@puremagic.com schrieb am 2006-12-03:
> http://d.puremagic.com/issues/show_bug.cgi?id=640

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

Added to DStress as http://dstress.kuehne.cn/nocompile/b/expression_4154_A.d http://dstress.kuehne.cn/nocompile/b/expression_4154_B.d http://dstress.kuehne.cn/run/b/expression_4154_C.d

Thomas


April 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=640


thomas-dloop@kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #2 from thomas-dloop@kuehne.cn  2007-04-27 12:36 -------
fixed URLs: http://dstress.kuehne.cn/nocompile/e/expression_4154_A.d http://dstress.kuehne.cn/nocompile/e/expression_4154_B.d http://dstress.kuehne.cn/run/e/expression_4154_C.d


-- 

July 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=640


kinaba@is.s.u-tokyo.ac.jp changed:

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




------- Comment #3 from kinaba@is.s.u-tokyo.ac.jp  2007-07-12 23:49 -------
The spec introduced at D 2.001/1.017
> The .init property for a variable is now based on its type, not its initializer.
fixed this problem.


--