www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [dmd v0.107 win32] Class member initialize

reply k2 <k2_member pathlink.com> writes:
class S {
int s;
this()
{
}
}


class A : S {
int a;
int b;
int c;
int d;
}

void main()
{
A a = new A;

printf("%d\n", a.s);
printf("%d\n", a.a);
printf("%d\n", a.b);
printf("%d\n", a.c);
printf("%d\n", a.d);
}

-- outputs
0
0
4264420
8850976
0
Nov 30 2004
next sibling parent reply "Simon Buchan" <currently no.where> writes:
On Tue, 30 Nov 2004 10:08:44 +0000 (UTC), k2 <k2_member pathlink.com>  
wrote:

 class S {
 int s;
 this()
 {
 }
 }


 class A : S {
 int a;
 int b;
 int c;
 int d;
 }

 void main()
 {
 A a = new A;

 printf("%d\n", a.s);
 printf("%d\n", a.a);
 printf("%d\n", a.b);
 printf("%d\n", a.c);
 printf("%d\n", a.d);
 }

 -- outputs
 0
 0
 4264420
 8850976
 0
I get
 "main.exe"
0 0 0 0 0
 Terminated with exit code 2.
-- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" "Clearly, if I were one of that Predator hunting team, I would file a complaint with my local member asking why such an unsafe environment should be allowed to continue, tradition or not." - http://www.sydneyanglicans.net/culture/watching/alien_vs_predator/
Nov 30 2004
parent k2 <k2_member pathlink.com> writes:
I'm using Windows 2000.
If add constructor to class A, I get right result.

In article <opsh9zh6l7jccy7t simon.homenet>, Simon Buchan says...
On Tue, 30 Nov 2004 10:08:44 +0000 (UTC), k2 <k2_member pathlink.com>  
wrote:

 class S {
 int s;
 this()
 {
 }
 }


 class A : S {
 int a;
 int b;
 int c;
 int d;
 }

 void main()
 {
 A a = new A;

 printf("%d\n", a.s);
 printf("%d\n", a.a);
 printf("%d\n", a.b);
 printf("%d\n", a.c);
 printf("%d\n", a.d);
 }

 -- outputs
 0
 0
 4264420
 8850976
 0
I get
 "main.exe"
0 0 0 0 0
 Terminated with exit code 2.
Nov 30 2004
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Added to DStress as
http://svn.kuehne.cn/dstress/run/class_initialization_01.d
http://svn.kuehne.cn/dstress/run/class_initialization_02.d

Thomas

k2 schrieb am Tue, 30 Nov 2004 10:08:44 +0000 (UTC):
 class S {
 int s;
 this()
 {
 }
 }


 class A : S {
 int a;
 int b;
 int c;
 int d;
 }

 void main()
 {
 A a = new A;

 printf("%d\n", a.s);
 printf("%d\n", a.a);
 printf("%d\n", a.b);
 printf("%d\n", a.c);
 printf("%d\n", a.d);
 }

 -- outputs
 0
 0
 4264420
 8850976
 0
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.12 (GNU/Linux) iD8DBQFBrdCa3w+/yD4P9tIRAtDlAJ9Fg2MXp6QTmHS0crDIC+6OuWeF2wCePJFP 7T5bg0fvCcyJ92kdWD+o1DQ= =Y4Wk -----END PGP SIGNATURE-----
Dec 01 2004