Thursday, 5 September 2013

Why is behavior different between gcc and llvm?

Why is behavior different between gcc and llvm?

I'm struggling with compiling some open source libraries, and then I ran
into this:
GLfloat campos[3] = {0.0 + modelview[2], 0.0 + modelview[6], 0.0 +
modelview[10]};
This compiles fine on CentOS, using gcc, and I really expected it to.
But then, on the Mac, using XCode with llvm, it won't compile, and I had
to change it to:
GLfloat campos[3] = static_cast<GLfloat>(0.0 + modelview[2]),
static_cast<GLfloat>(0.0 + modelview[6]), static_cast<GLfloat>(0.0 +
modelview[10]);
And then it worked. For reference, modelview is another GLFloat, like so:
GLfloat modelview[16];
Since modelview is a GLFloat, the static_cast is being applied to the
result of a sum of float with a GLfloat, but I did expect to get this for
free.
Why is behavior different?

No comments:

Post a Comment