Hi,

Gerrit Voss wrote:
> On Sun, 2008-06-15 at 18:08 +0200, Ákos Balázs wrote:
>> On Wed, Jun 11, 2008 at 1:22 AM, Ákos Balázs <[EMAIL PROTECTED]> wrote:
>>> See the attachment. The patch is against the current CVS tree. Looking
>>> at it again I think the patch to OSGBaseFunctions.inl is only
>>> necessary because I've included the "-ansi" compiler option, without
>>> it it should compile on OS X as is. Now there seem to be some problems
>>> related to the functor stuff so some of the BaseTests don't build, but
>>> the segfault at exit seems to be gone now. :)
>> Following up on myself (I love doing that :-) I think I fixed the
>> problems with the BaseTests. It seems that Gerrit's commits that
>> changed the C-style casts to  static_casts broke the BaseTests.
>> Curoiusly only ``testfunctors.cpp'' from the BaseTests package seems
>> to be affected, everything else works fine. I don't claim to know half
>> as much about C++ as Gerrit does, but AFAIU
>> the C++ casting rules in this case the dreaded reinterpret_cast must
>> be used instead of static_cast since the cast is between two unrelated
>> pointer types (neither of which is a pointer to void), so I think the
>> compiler (in my case gcc 4.0) is right here. I've attached a patch
>> against the current CVS that fixes this.
> 
> yeah my fault ;-), but I treat reinterpret_casts quite carefully,
> especially since gcc started to use structural information
> to optimise. So that's why some static_casts are still there
> if I did not hit a compiler complain.

yes, reinterpret_cast is a big hammer and depending on how clever the 
compiler tries to be somewhat dangerous. The c++ the standard basically 
only guarantees that casting a pointer to something and back again 
works, everything else is implementation defined behavior.
IIRC boost solves such cases by doing a static_cast to void * and then a 
static_cast to the destination pointer type. I remember reading a post 
on their list that this is the only fully portable way to do certain 
types of casting - they were not happy about that either ;)

        Carsten

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to