avoid type aliasing
authorThomas Hartmann <Thomas.Hartmann@nokia.com>
Thu, 10 Nov 2011 10:16:56 +0000 (11:16 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 11 Nov 2011 08:16:21 +0000 (09:16 +0100)
commite82b120410820e978b87b0a0f3b99718f3671fb1
tree535869d543ded89ac08c653305f6bb3ffb717eb3
parent64c8691548d357d34521ec698050cf4d442eee3d
avoid type aliasing

For -O2 gcc activates -fstrict-aliasing. As a result the compiler is
allowed to assume that pt[1]=px[1]/3+B1 does not affect t.

Therefore the result of _fast_cbrt() was always 0.
Using a union for casting avoids this issue.

For more details see:
http://labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing

Also the updated code respect endianness.

Change-Id: Id4bed16efac52e494e7357dc2f23f94e8c525df1
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qeasingcurve.cpp