I'm working with the default C++ compiler (I guess it's called the "Visual Studio C++ compiler") that comes with Visual Studio 2013 with the flag /Ox
(Full Optimization). Due to floating point side effects, I must disable the -ffast-math
flag when using the gcc
compiler. Is there an equivalent option for this flag in the configuration of the Visual Studio C++ compiler?
Asked
Active
Viewed 8,671 times
11
-
1Note that disabling `-ffast-math` in gcc means not passing that option, it is more like "not enabling". – Marc Glisse Oct 21 '14 at 19:17
2 Answers
13
You are looking for /fp:precise
, although that is also the default.
If you need the strictest floating point calculations that VS can offer, try /fp:strict
, although that is probably overkill.
You probably have nothing to worry about since the default behavior should be what you desire. Just make sure that /fp:fast
is not specified, but if you try to compile with both /fp:fast
and /fp:precise
you will get a compilation error anyway, so that should be easy to catch.
The link that Hans Passant provided to the MSDN website provides all the details you might want.

pattivacek
- 5,617
- 5
- 48
- 62
-3
None of the MSVC++ options enable the optimizations which are invoked by g++ -ffast-math
.
-
1
-
Microsoft /fp:fast doesn't invoke those optimizations. You may be confused by the conflicting Intel C++ usage where fast=2 does operate similar to g++ -ffast-math ( and fast=1 invokes the important ones, except for complex limited range). – tim18 Jul 20 '17 at 17:45
-
obviously it may not be exactly the same but it does specify the floating-point operations behavior **which is what the OP asked**. He didn't ask about all `-ffast-math` side effects – phuclv Jul 21 '17 at 01:01
-
Does `-ffast-math` included in `-O3` in GCC? Because it seems in my project ([Image Convolution](https://github.com/RoyiAvital/Projects/tree/master/ImageConvolution)) that MSVC 2015 generate much faster code than GCC 7.1. – Royi Aug 05 '17 at 10:01
-