Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 19, 2004 Dernel: dynamic arrays | ||||
---|---|---|---|---|
| ||||
Hi, I have the following code, that makes some problems.
This works:
char[] str1 = "abc";
k_println(str1);
And this part fails:
Object obj1;
char[] str1;
str1 = obj1.toString();
k_println(str1);
What's happening at the line with the assignment? The code compiles without any unresoleved reference errors but bombs. This is the ASM output, of the second code snippet.
push EBP
mov EBP,ESP
xor EAX,EAX
mov ECX,[EAX]
call dword ptr 8[ECX]
push EDX
push EAX
call near ptr _D6kernel7console7printlnFAaZv
pop EBP
ret
What is this "call dword ptr 8[ECX]" thing? Is this a call thru the vtable of the object? It seems, that my stack pointer is wrong. But I don't do anything with it. Maybe that's the problem...
--
Robert M. Münch
Management & IT Freelancer
http://www.robertmuench.de
|
February 19, 2004 Re: Dernel: dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | your object is a null reference.. or have you obj = new Obj; somewhere? "Robert M. Münch" <robert.muench@robertmuench.de> schrieb im Newsbeitrag news:opr3lzklwium5vd8@news.digitalmars.com... > Hi, I have the following code, that makes some problems. > > This works: > char[] str1 = "abc"; > k_println(str1); > > And this part fails: > Object obj1; > > char[] str1; > str1 = obj1.toString(); > k_println(str1); > > What's happening at the line with the assignment? The code compiles without any unresoleved reference errors but bombs. This is the ASM output, of the second code snippet. > > push EBP > mov EBP,ESP > xor EAX,EAX > mov ECX,[EAX] > call dword ptr 8[ECX] > push EDX > push EAX > call near ptr _D6kernel7console7printlnFAaZv > pop EBP > ret > > What is this "call dword ptr 8[ECX]" thing? Is this a call thru the vtable of the object? It seems, that my stack pointer is wrong. But I don't do anything with it. Maybe that's the problem... > > -- > Robert M. Münch > Management & IT Freelancer > http://www.robertmuench.de |
February 20, 2004 Re: Dernel: dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | On Thu, 19 Feb 2004 15:32:38 +0100, davepermen <davepermen@hotmail.com> wrote: > your object is a null reference.. or have you obj = new Obj; somewhere? Hi, no, because it's a (local) stack object. Or is this not supported? IIRC this is totaly legal. Robert -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de |
June 23, 2004 Re: Dernel: dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert M. Münch | "Robert M. Münch" <robert.muench@robertmuench.de> wrote in message news:opr3n2w8yoheztw6@news.digitalmars.com... > On Thu, 19 Feb 2004 15:32:38 +0100, davepermen <davepermen@hotmail.com> wrote: > > > your object is a null reference.. or have you obj = new Obj; somewhere? > > Hi, no, because it's a (local) stack object. Or is this not supported? IIRC this is totaly legal. Robert Class objects are not on the stack; you'll need to new them. |
Copyright © 1999-2021 by the D Language Foundation