Hello Carsten,

"Carsten Neumann" <carsten_neum...@gmx.net> schrieb im 
Newsbeitrag news:4c4dbd03.5060...@gmx.net...
>>
>> I could verify that everything is fine to the point of the return call.
>> However, variable v is not correctly intialized afterwards.
>
> oh, my favourite C++ programming rules, aliasing ;) My hope in writing
> the above had been that due to the special casing of 'char' in the
> aliasing rules the conversion would be safe  :-/
>
No, I do not think that it is an aliasing problem. After applying your patch 
the behavior did not change. I have minutely debugged and see the same bit 
switch on assigment to variable v in function

ExceptionBinaryDataHandler::putValue(const Real32& value)


For example: In function

template<> inline
OSG::Real32 osgSwapBytes<Real32>(OSG::Real src)
{
    union
    {
        OSG::Real32 floatVal;
        OSG::UInt32 intVal;
    } unionVal;

    unionVal.floatVal = src;
    unionVal.intVal = osgSwapBytes(unionVal.intVal);

    return unionVal.floatVal;
}

I got at the address of unionVal the following: 43 ea 91 ff

After assignment to variable v I got at the address of v: 43 ea d1 ff

I take my suspicion that the problem is related to the numerics. I do not 
believe that it is reasonable to expect the runtime to copy/assign real 
numbers only with respect to their bit representation uniformely on all 
platforms. The math coprocessor is typically involved on x86.

Maybe someone with knowledge in this matter does listen and can give a 
statement?

Anyhow, I like the alignment code trick. I did ones see something along the 
line in the 'Modern C++ Design' book form A.Alexandrescu.

Best,
Johannes




------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to