Details
-
Bug
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
4.7.0
-
None
Description
Using Qt from a product that has configured the FPU to be in extended precision mode. In this case, qdtoa() can produce strange strings. For example, the value 2121 produces a string 2121.:00.
I have not tested this in versions newer than 4.5.2.
Also, it only seems to happen in release builds.
I have not yet distilled all of this down to a simple example.
In msvc 7.1 builds of 4.3.1, rather than modifying the "_control87(MCW_EM, MCW_EM);" call in qdtoa() to " _control87(MCW_EM | _PC_53, MCW_EM | _MCW_PC);", building with the /Op optimization flag seemed to avoid the problem. I'm not sure, however, what other side effects that may have throughout the entire Qt codebase or the larger application using Qt.
In msvc90 and later, I believe the -fp:strict flag is necessary - -fp:precise does not solve the problem.
It seems that having the FPU in extended mode has effects in the _qdtoa() function. I debugged this long ago (in 2008, issue N204437), but this line in _qdtoa() seems to be where things started to go wrong:
ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
Later, you find this calculation:
L = Long(d / ds);
In the problematic builds, I observed that L rounds to zero, while in the 'correct' ones, this value rounds to one when 'd' is 1000.0.