If you read the article you find that this is a bug in MinGW64 libraries.<p>It's not a compiler bug, it's not a problem in C/C++, or even in IEEE-754 floating point math. The MinGW64 thread library simply forgot to initialize the FPU correctly.<p>He'd have had the same problem if he wrote his code in assembly language and then ran it in a MinGW64 thread.
> <i>This means that floating point arithmetic is non-associative. In that A + B != B + A.</i><p>The equation is the commutative property, not associative. IIRC addition in IEEE-754 is commutative.<p>The property that fails is (A+B)+C = A+(B+C).
>"Compiler bug? But how…
Looking at the code, the only things that could create the bug were the operators and pow() call. These are part of the C++ standard offering so it’s highly unlikely that either of these would have an error. What next? Off to GodBolt to try some other compilers to see if I get wonky results on them. MSVC++… nope, Clang… nope, GCC-Trunk on Linux… nope. I am only getting this weird behaviour in TDM-GCC. Time to try some other MingW64 compilers. Nuwen… Yes, Mingw64.. yes, TDM-GCC… yes.<p>Confirmed: It’s a bug in MinGW64.<p>When I create a new thread and run floating point operations in that thread, I get slightly different answers."<p>Interesting!
Do <i>not</i> use C/C++ for numerical code where accuracy is needed. These languages are not specified to conform to IEEE 754 and you are absolutely asking for trouble.