printf will cause it to work because the floating point number will be converted from the internal FPU 80-bit representation (assuming x86 "old-style" math) to the 64-bit that is saved in a double.
The reason for this is that the register value has to be moved to the stack when you call another function (again, assuming x86 old-style FPU calling conventions), which will cause it to be rounded to 64bits of precision.
Your other compilations most likely works because they are using SSE2+ math, which has a native 64-bit floating point type.
==
tests that the floats are identical, which is almost never the correct thing to do with floating point numbers.
In this case it is not since the internal CPU representation differs from the one that is stored in a double.
When comparing floating point numbers, always check if they are close enough to each other instead of being equal.
#include <math.h>
QVERIFY( fabs(res-tmp) < DBL_EPSILON )