call to super trashes pointer?
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 23 03:05:06 PST 2016
On Tuesday, 23 February 2016 at 10:47:17 UTC, Rene Zwanenburg
wrote:
> On Tuesday, 23 February 2016 at 09:16:08 UTC, Nicholas Wilson
> wrote:
>> struct A
>> {
>> int blah;
>> }
>> class B
>> {
>> A* a;
>> this(A* _a)
>> {
>> writeln(_a)
>> a =_a;
>> }
>> }
>>
>> class C : B
>> {
>> this(A* _a)
>> {
>> writeln(_a)
>> super(_a);
>> }
>> }
>> int main(string[] args)
>> {
>> A a;
>> writeln(&a);
>> C c = new C(&a);
>> }
>>
>> prints
>> 7FFF56E787F8
>> 7FFF56E787F8
>> null
>>
>> ??? What is happening here?
>
> I can't reproduce this. After making a few changes to get the
> code to compile (adding ; after the first two writeln's, and
> changing int main to void main), everything works as expected.
> Which compiler and version are you using?
v2.067-devel-e431363
I "fixed" it see above.
More information about the Digitalmars-d-learn
mailing list