Y
Hacker News
new
|
ask
|
show
|
jobs
by
gpderetta
720 days ago
You can set fast math (or a subset of it) on a translation unit basis.
3 comments
tialaramex
720 days ago
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.
link
gpderetta
720 days ago
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.
link
pdw
720 days ago
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...
link
gpderetta
720 days ago
To enable this "feature" I believe you have to specify fast math while linking the .so, it is not enough to do it when compiling.
It had also been fixed recent GCC versions.
link
cozzyd
720 days ago
Or even on a per function basis, at least with gcc (no clue about clang...)
link
gpderetta
720 days ago
In principle yes, you can use Attribute optimize, but I wouldn't rely on it. Too many bugs open against it.
link
cozzyd
720 days ago
It's worked for me in the past but maybe I got lucky.
link