www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 640] New: Strage error messages around structInstance.init

reply d-bugmail puremagic.com writes:
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;
}


-- 
Dec 03 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFFfEFVLK5blCcjpWoRAudDAJ99lH4s96OIIp3kKTdU4Eab2raSvgCdHlFh JRhifgfKTSJpL6tdKxLodEE= =LyJw -----END PGP SIGNATURE-----
Dec 10 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
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


-- 
Apr 27 2007
prev sibling parent d-bugmail puremagic.com writes:
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.

--
Jul 12 2007