Mail Archives: cygwin-developers/2002/09/28/19:07:05
--=-bXM/NCYZY3UtTkmXmadN
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
On Sun, 2002-09-29 at 04:37, egor duda wrote:
> I guess i know why it works for you. Hint: Try gcc 3.x to build
> cygwin1.dll. Me and Chris, are using it, obviously, while you're
> probably using 2.95, right?
Yes, I've been holding off upgrading until gcc 3.x is the default for
cygwin, at which time I will migrate the setup sources to 3.x.
=20
> class verifyable_object contains no virtual functions, hence no
> pointer to VMT in it. This means that compiler assumes that magic
> member is placed at offset 0 from the beginning of class.=20
Which is valid for verifyable_object but will *kill* any derived
classes. Yep. coding bug on my behalf. Can you or Chris try the test run
after changing the verifyable_object destructor to be virtual (thread.h,
line 163).
> class
> pthread is a subclass of class verifyable_object, but it _does_
> have VMT to accommodate virtual method 'create'. As far as i can
> understand from assembly, pointer to VMT is placed at the beginning of
> object instance, at offset 0, while members are placed after it, so
> 'magic' has offset 4.
Thank you for digging, I imagine this took some time - and you've saved
me a lot of head scratching.=20
=20
> Now, in verifyable_object_isvalid you're casing pointer to variable of
> subclass to pointer to base class. Ain't it case of 'never do like
> this'? I suppose to safely perform cast from subclass to base class
> one should always use dynamic_cast().
It's a case of this is always ways ok to do - upcasting is FINE.. (it
happens every time you call a virtual function in fact).
It's never ok to case a base class to a subclass (known as downcasting)
unless you use a static_cast or a dynamic_cast.
http://www.cs.rpi.edu/~wiseb/xrds/ovp3-1.html
What *may* be a regression in 3.2 is the apparent bug caused by the
introduction of a VMT in a derived class. However, as we already have a
destructor for verifyable_object, and in this instance it should be
virtual, we get to sidestep the bullet - for now.
Rob
--=20
---
GPG key available at: http://users.bigpond.net.au/robertc/keys.txt.
---
--=-bXM/NCYZY3UtTkmXmadN
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQA9ljY2I5+kQ8LJcoIRAjURAJ9bRKg6+K3OVJdOZ1U8sZYQmZElDQCfacyb
eyV9a4olb02z+7AcO4eX04Y=
=jrdh
-----END PGP SIGNATURE-----
--=-bXM/NCYZY3UtTkmXmadN--
- Raw text -