0

How do I disable fast math for a function defined in header file or for the entire source file?

#pragma GCC optimize ("no-fast-math")

Adding the line above to both (source file and header file) doesn't seem to work in this case.

Martin
  • 29
  • 5
  • Note: Doing stuff like this in a header will infect all files that include the header. That can be an extremely nasty shock for the unwary. – user4581301 May 21 '20 at 19:40
  • The approach should be correct - https://godbolt.org/z/aTEmGQ. You should try to create minimal reproducible example and specify compiler version, command line arguments and why it seems does not working. – dewaffled May 21 '20 at 20:26
  • And it is indeed much safer to use such pragmas in combination with `GCC push_options` and `GCC pop_options` to always restore previous behavior so it does not suddenly change depending on included files and the include order. – dewaffled May 21 '20 at 20:30
  • A piece of code which doesn't work when fast math is enabled can be seen in this question: https://stackoverflow.com/questions/61938228/strange-while-loop-behavior – Martin May 21 '20 at 21:08

0 Answers0