www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2002/09/28/15:26:38

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Date: Sat, 28 Sep 2002 23:24:50 +0400
From: egor duda <deo AT logos-m DOT ru>
Reply-To: egor duda <cygwin-developers AT cygwin DOT com>
Organization: deo
X-Priority: 3 (Normal)
Message-ID: <24645661722.20020928232450@logos-m.ru>
To: Christopher Faylor <cygwin-developers AT cygwin DOT com>
Subject: Re: Many pthread failures in the test suite, one setgroup failure
In-Reply-To: <20020928185921.GA8253@redhat.com>
References: <20020925141653 DOT GA6134 AT redhat DOT com>
<1033139976 DOT 22908 DOT 333 DOT camel AT lifelesswks>
<163544913434 DOT 20020927192540 AT logos-m DOT ru> <1033140780 DOT 9593 DOT 0 DOT camel AT lifelesswks>
<44642850720 DOT 20020928223759 AT logos-m DOT ru> <20020928185921 DOT GA8253 AT redhat DOT com>
MIME-Version: 1.0

Hi!

Saturday, 28 September, 2002 Christopher Faylor cgf AT redhat DOT com wrote:

CF> On Sat, Sep 28, 2002 at 10:37:59PM +0400, egor duda wrote:

>>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. 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.
>>
>>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().

CF> Hmm.  I thought it was always legal to coerce a pointer to a subclass
CF> to a pointer to the base class.  Did you try a dynamic cast to see
CF> if it worked?

No. I'll try to, but i'm afraid it will require some rewrite of
verifyable_object framework. Explanation below.

*** WARNING *** the following is a speculation on the basis of
information taken from the web 5 minutes ago *** WARNING ***

As far as i can understand dynamic_cast syntax (i've never looked
at it before, so i may be wrong here), you can't perform dynamic_cast
from void* pointer. dynamic_cast is simple addition or substraction of
some fixed value from class pointer. This fixed value is computed at
compile time when compiler generates class instances layout for
classes which are used in dynamic_cast. So, verifyable_object_isvalid
should take verifyable_object pointer, while callers should perform
dynamic_cast before calling verifyable_object_isvalid ()

Or, isvalid should be simply made virtual method for
verifyable_object, thus eliminating the need of dynamic_cast) at all.

CF> Anyway, thanks for the detailed analysis, Egor.  I was actually
CF> wondering if this was a gcc 3.2 "problem".  It must be a gcc 3.3
CF> problem, also, since my normal compiler is gcc 3.3.

I suspect that only (possible) problem with gcc is that it doesn't
warn about such casting. I'm not sure even if it's possible for
compiler to detect it to print warning.

Egor.            mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019