Thread overview | |||||
---|---|---|---|---|---|
|
April 22, 2005 [adress op] sudden AV | ||||
---|---|---|---|---|
| ||||
All asserts should path, but do not: <code> class C{ void f(){}; void opCall(){ assert( &f); printf("assert 2 passed.\n"); } struct S{ void opCall(){ assert( &f); printf("assert 3 passed.\n"); } } S s; } void main(){ C c= new C; assert( &(c.f)); printf("assert 1 passed.\n"); c(); c.s(); } </code> |
April 22, 2005 Re: [adress op] sudden AV | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | In article <d4apqu$2bo2$1@digitaldaemon.com>, Manfred Nowak says... > >All asserts should path, but do not: > ><code> >class C{ > void f(){}; > > void opCall(){ > assert( &f); > printf("assert 2 passed.\n"); > } > > struct S{ > void opCall(){ > assert( &f); > printf("assert 3 passed.\n"); > } > } S s; >} >[...] This is not supposed to work, since the struct S has no link to any instance of the class C, and hence no pointer to the function f (f is a virtual function, so without a class instance you have no pointer.) In fact it shouldn't even compile, since f isn't well defined in S. Nick |
April 23, 2005 Re: [adress op] sudden AV | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Manfred Nowak schrieb am Fri, 22 Apr 2005 12:14:22 +0000 (UTC): > All asserts should path, but do not: > ><code> > class C{ > void f(){}; > > void opCall(){ > assert( &f); > printf("assert 2 passed.\n"); > } > > struct S{ > void opCall(){ > assert( &f); > printf("assert 3 passed.\n"); > } > } S s; > } > void main(){ > > C c= new C; > > assert( &(c.f)); > printf("assert 1 passed.\n"); > c(); > c.s(); > > } ></code> Added to DStress as http://dstress.kuehne.cn/nocompile/scope_02.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCae7p3w+/yD4P9tIRAqJRAJ4n3D7YtQgNiBTJi+kJy6IsrGnPHgCgjUer G5gVdi3qwHcWwBrg5tK/MdU= =+vxA -----END PGP SIGNATURE----- |
Copyright © 1999-2021 by the D Language Foundation