Re:Own Constant Folder in C/C++
by gpderetta on Saturday June 22, 2024 @10:52AM
(#40759512)
You can set fast math (or a subset of it) on a translation unit basis.
[ Parent
| on HN ]
Re:Own Constant Folder in C/C++
by tialaramex on Saturday June 22, 2024 @12:59PM
(#40760424)
Because the language works by textual inclusion and so a "translation unit" isn't really just your code this is much more likely to result in nasty surprises, up to and including ODR violations.
Yes, if you try hard enough I'm sure you can find ways to screw up.
From a practical point of view it is fine.
Or even on a per function basis, at least with gcc (no clue about clang...)
In principle yes, you can use
Attribute optimize, but I wouldn't rely on it. Too many bugs open against it.
It's worked for me in the past but maybe I got lucky.
That's not really true. If you link a shared library that was compiled with -ffast-math, that will affect the entire program. https://moyix.blogspot.com/2022/09/someones-been-messing-wit...