3 ms·
Great point. It's also worth remembering that optimizations such as floating point at O3 will trade away accuracy for speed. C compilers are willing to give you
by nickpsecurity 12y ago
Great point. It's also worth remembering that optimizations such as floating point at O3 will trade away accuracy for speed. C compilers are willing to give you... the wrong result... but faster than ever! Undefined behavior is another fun line of inquiry. Best to learn about the dark corners and avoid them where possible.
- tspiteri 12y agoNo, you don't get inaccurate floating-point results just by using a higher level of optimization. For example, gcc requires an explicit -ffast-math option for that kind of optimization.
- Narishma 12y agoThere's an explicit compiler flag to get fast but not accurate math and it isn't enabled in any of the -On presets in either gcc or clang.
- nickpsecurity 12y agoMy original source was wrong. Thanks for the correction you two!