Ok,
My colleague and I tested several fixes to see where the problem might
be coming from. So here are our current findings:
- The problem appears on both VS2005 SP1 and VS2008 SP1.
- The problem appears to be an invalid compiler optimization
when unrolling the second loop.
- Declaring "int a" as volatile fixes the problem
- Moving "vc" from the global scope into the local scope fixes
the problem
- Changing the "Vec3f::operator -" implementation fixes the
problem
We haven't reported the bug to Microsoft yet, as my colleague thinks it
could be an obscure C++ standard specification issue about class
operators that allows compilers to make invalid optimizations in some
cases.
Could anyone test other compilers? I've attached a standalone test
program based on Guy's.
Cheers,
Tanguy
PS: Sorry for the previous empty email. Hit the send button a bit too
quickly.
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Tanguy
Fautre
Sent: Thursday 29 January 2009 12:23
To: OpenSceneGraph Users
Subject: Re: [osg-users] MSVC v9
Apparently, it's also broken on VC8.
I've reduced the size of the example program, removed the OSG
dependency, and getting ready to submit to MS.
T
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Tanguy
Fautre
Sent: Thursday 29 January 2009 11:43
To: OpenSceneGraph Users
Subject: Re: [osg-users] MSVC v9
Hi Guy,
I was able to reproduce the problem on my computer too.
You got my colleagues and I quite puzzled. At this point it's very
tempting to say it's a compiler bug.
I'll do some more investigation. If you don't mind, I'll submit this bug
to Microsoft if we cannot fix it.
Tanguy
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Guy
Wallis
Sent: Thursday 29 January 2009 03:38
To: OpenSceneGraph Users
Subject: [osg-users] MSVC v9
First, sorry Jan!
I'm new to mailing lists and assumed that threads were generated on the
basis of the subject line not who I replied to. Thanks for pointing out
my mistake.
Second, thanks to Tanguy and Ralph for suggestions.
I'm using an old 2.8 Ghz Pentium 4 - so not a dual core problem. But the
error does remind me of threading issues I used to have with
multiprocessor IRIX machines.
I tried using the volatile type qualifier but then I got a load of
conversion errors because MSVC++ v9 didn't recognise the variable as an
osg::Vec3 anymore:
.\dodec.cpp(78) : error C2678: binary '-' : no operator found which
takes a left-hand operand of type 'volatile osg::Vec3' (or there is no
acceptable conversion)
C:\Program Files\OpenSceneGraph\include\osg/Vec3f(152): could be
'const osg::Vec3f osg::Vec3f::operator -(const osg::Vec3f &) const'
C:\Program Files\OpenSceneGraph\include\osg/Vec3f(167): or
'const osg::Vec3f osg::Vec3f::operator -(void) const'
I've distilled the problem into a pretty simple program - I don't even
need to pop up a window. Some things might look a little odd, but almost
any changes from this point result in correct behaviour. I'm expecting a
list of coordinates from (0.0, 0.0, 0.0) to (11.0, 11.0, 11.0) but as
you'll hopefully see, I get the central part of the array not updating
properly.
#include
osg::Vec3 vc[12];
int main( int argc, char **argv )
{
int a;
osg::Vec3 vt[12], p;
for(a=0;a<12;a++){
vc[a].set((float)a, (float)a, (float)a+1.0f);
}
p = osg::Vec3(0.0f,0.0f,1.0f);
vt[0] = vc[0]-p;
for(a=1;a<12;a++){
vt[a] = vc[a]-p;
}
for(a=0;a<12;a++){
printf("%5.2f %5.2f %5.2f\n", vt[a].x(), vt[a].y(),
vt[a].z());
}
return 0;
}
Two crucial steps are the vc[a]-p stage, and using the local variable vt
for printing because otherwise the array updates correctly.
Any ideas? Such as leave it for Microsoft to sort out!
Thanks,
Guy
main.cpp
Description: main.cpp
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org