there are 2 bad aliasing in the ImfFloatToHalf (float f, ImfHalf *h) function, making compilers and analyzers cry as it does not follow the aliasing rules... easily fixed with a memcpy:
short half = FloatToHalf( (int)&f );
is replaced by
int x;
memcpy((void *)&x,(const void *)&f,sizeof(float));
short half = FloatToHalf(x);
(same for ImfHalf cast).
Assembly generated is exactly the same (on my machine) but compiler is happy and code is now safe if aggressive optimization is turn on.
Cheers,
there are 2 bad aliasing in the ImfFloatToHalf (float f, ImfHalf *h) function, making compilers and analyzers cry as it does not follow the aliasing rules... easily fixed with a memcpy:
short half = FloatToHalf( (int)&f );
is replaced by
int x;
memcpy((void *)&x,(const void *)&f,sizeof(float));
short half = FloatToHalf(x);
(same for ImfHalf cast).
Assembly generated is exactly the same (on my machine) but compiler is happy and code is now safe if aggressive optimization is turn on.
Cheers,