You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`/FS`](fs-force-synchronous-pdb-writes.md)| Forces serialization of all writes to the program database (PDB) file through MSPDBSRV.EXE. |
55
55
|[`/fsanitize`](fsanitize.md)| Enables compilation of sanitizer instrumentation such as AddressSanitizer. |
56
+
|[`/fsanitize-coverage`](fsanitize-coverage.md)| Enables compilation of code coverage instrumentation for libraries such as LibFuzzer. |
56
57
|[`/FU`](fu-name-forced-hash-using-file.md)| Forces the use of a file name as if it had been passed to the [`#using`](../../preprocessor/hash-using-directive-cpp.md) directive. |
57
58
|[`/Fx`](fx-merge-injected-code.md)| Merges injected code with source file. |
58
59
|[`/GA`](ga-optimize-for-windows-application.md)| Optimizes code for Windows application. |
Copy file name to clipboardExpand all lines: docs/build/reference/fp-specify-floating-point-behavior.md
+56-7Lines changed: 56 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,54 @@ Specifies how the compiler treats floating-point expressions, optimizations, and
12
12
13
13
## Syntax
14
14
15
+
::: moniker range=">msvc-160"
16
+
17
+
**`/fp:contract`**
18
+
**`/fp:except`**\[**`-`**]\
19
+
**`/fp:fast`**\
15
20
**`/fp:precise`**\
16
21
**`/fp:strict`**\
17
-
**`/fp:fast`**\
22
+
23
+
::: moniker-end
24
+
::: moniker range="<=msvc-160"
25
+
18
26
**`/fp:except`**\[**`-`**]
27
+
**`/fp:fast`**\
28
+
**`/fp:precise`**\
29
+
**`/fp:strict`**\
30
+
31
+
::: moniker-end
19
32
20
33
### Arguments
21
34
35
+
::: moniker range=">msvc-160"
36
+
37
+
#### <aname="contract"></a> `/fp:contract`
38
+
39
+
The **`/fp:contract`** option allows the compiler to generate floating-point contractions when you specify the **`/fp:precise`** and **`/fp:except`** options. A *contraction* is a machine instruction that combines floating-point operations, such as Fused-Multiply-Add (FMA). FMA, defined as a basic operation by IEEE-754, doesn't round the intermediate product before the addition, so the result can differ from separate multiplication and addition operations. Since it's implemented as a single instruction, it can be faster than separate instructions. The speed comes at a cost of bitwise exact results, and an inability to examine the intermediate value.
40
+
41
+
By default, the **`/fp:fast`** option enables **`/fp:contract`**. The **`/fp:contract`** option isn't compatible with **`/fp:strict`**.
42
+
43
+
The **`/fp:contract`** option is new in Visual Studio 2022.
44
+
45
+
::: moniker-end
46
+
22
47
#### <aname="precise"></a> `/fp:precise`
23
48
24
49
By default, the compiler uses **`/fp:precise`** behavior.
25
50
26
51
Under **`/fp:precise`**, the compiler preserves the source expression ordering and rounding properties of floating-point code when it generates and optimizes object code for the target machine. The compiler rounds to source code precision at four specific points during expression evaluation: at assignments, typecasts, when floating-point arguments get passed to a function call, and when a function call returns a floating-point value. Intermediate computations may be performed at machine precision. Typecasts can be used to explicitly round intermediate computations.
27
52
28
-
The compiler doesn't perform algebraic transformations on floating-point expressions, such as reassociation or distribution, unless it can guarantee the transformation produces a bitwise identical result. Expressions that involve special values (NaN, +infinity, -infinity, -0.0) are processed according to IEEE-754 specifications. For example, `x != x` evaluates to **`true`** if `x` is NaN. Floating-point *contractions*, machine instructions that combine floating-point operations, may be generated under **`/fp:precise`**.
53
+
::: moniker range=">msvc-160"
54
+
55
+
The compiler doesn't perform algebraic transformations on floating-point expressions, such as reassociation or distribution, unless it can guarantee the transformation produces a bitwise identical result. Expressions that involve special values (NaN, +infinity, -infinity, -0.0) are processed according to IEEE-754 specifications. For example, `x != x` evaluates to **`true`** if `x` is NaN. Floating-point contractions aren't generated by default under **`/fp:precise`**. This behavior is new in Visual Studio 2022. Previous compiler versions could generate contractions by default under **`/fp:precise`**.
56
+
57
+
::: moniker-end
58
+
::: moniker range="<=msvc-160"
59
+
60
+
The compiler doesn't perform algebraic transformations on floating-point expressions, such as reassociation or distribution, unless it can guarantee the transformation produces a bitwise identical result. Expressions that involve special values (NaN, +infinity, -infinity, -0.0) are processed according to IEEE-754 specifications. For example, `x != x` evaluates to **`true`** if `x` is NaN. Floating-point contractions may be generated under **`/fp:precise`**.
61
+
62
+
::: moniker-end
29
63
30
64
The compiler generates code intended to run in the [default floating-point environment](#the-default-floating-point-environment). It also assumes the floating-point environment isn't accessed or modified at runtime. That is, it assumes the code doesn't unmask floating-point exceptions, read or write floating-point status registers, or change rounding modes.
31
65
@@ -49,7 +83,7 @@ Under **`/fp:fast`**, the compiler generates code intended to run in the default
49
83
50
84
#### <aname="except"></a> `/fp:except`
51
85
52
-
The **`/fp:except`** option generates code to ensures that any unmasked floating-point exceptions are raised at the exact point at which they occur, and that no other floating-point exceptions are raised. By default, the **`/fp:strict`** option enables **`/fp:except`**, and **`/fp:precise`** doesn't. The **`/fp:except`** option isn't compatible with **`/fp:fast`**. The option can be explicitly disabled by us of **`/fp:except-`**.
86
+
The **`/fp:except`** option generates code to ensures that any unmasked floating-point exceptions are raised at the exact point at which they occur, and that no other floating-point exceptions are raised. By default, the **`/fp:strict`** option enables **`/fp:except`**, and **`/fp:precise`** doesn't. The **`/fp:except`** option isn't compatible with **`/fp:fast`**. The option can be explicitly disabled by use of **`/fp:except-`**.
53
87
54
88
By itself, **`/fp:except`** doesn't enable any floating-point exceptions. However, it's required for programs to enable floating-point exceptions. For more information on how to enable floating-point exceptions, see [`_controlfp`](../../c-runtime-library/reference/control87-controlfp-control87-2.md).
55
89
@@ -63,11 +97,26 @@ The [`/Za`](za-ze-disable-language-extensions.md) (ANSI compatibility) option is
63
97
64
98
The compiler provides three pragma directives to override the floating-point behavior specified on the command line: [`float_control`](../../preprocessor/float-control.md), [`fenv_access`](../../preprocessor/fenv-access.md), and [`fp_contract`](../../preprocessor/fp-contract.md). You can use these directives to control floating-point behavior at function-level, not within a function. These directives don't correspond directly to the **`/fp`** options. This table shows how the **`/fp`** options and pragma directives map to each other. For more information, see the documentation for the individual options and pragma directives.
The **`/fsanitize-coverage`** compiler options instruct the compiler to add various kinds of instrumentation points where user-defined functions are called. These options are useful for fuzzing scenarios that use **`/fsanitize=fuzzer`**, like OneFuzz. For more information, see the [OneFuzz documentation](https://www.microsoft.com/en-us/research/project/project-onefuzz/) and [OneFuzz GitHub project](https://github.com/microsoft/onefuzz).
The experimental **`/fsanitize-coverage`** compiler options offer code coverage support and various options to modify which compiler-provided instrumentation is generated. All these options are automatically set when the [`/fsanitize=fuzzer`](fsanitize.md) option is specified. The **`/fsanitize=fuzzer`** option requires the same instrumentation points and callbacks mentioned in these options.
26
+
27
+
The **`/fsanitize-coverage`** options don't allow comma-separated syntax, for example: **`/fsanitize-coverage=edge,inline-8bit-counters,trace-cmp,trace-div`**. Specify these options individually.
28
+
29
+
The **`/fsanitize-coverage`** options are available beginning in Visual Studio 2022 version 17.0.
30
+
31
+
### Code coverage
32
+
33
+
The **`/fsanitize-coverage=edge`** compiler option enables code coverage instrumentation along all non-redundant edges. Use **`/fno-sanitize-coverage=edge`** to disable this option if it's already provided or implied by another option.
34
+
35
+
### Inline counters
36
+
37
+
The **`/fsanitize-coverage=inline-8bit-counters`** compiler option instructs the compiler to add an inline counter increment on every relevant edge. This option also adds a call to `extern "C" void __sanitizer_cov_8bit_counters_init(uint8_t *start, uint8_t *stop)` that you must implement. The arguments correspond to the start and end of an array that contains all the 8-bit counters created. Use **`/fno-sanitize-coverage=inline-8bit-counters`** to disable this option if it's already provided or implied by another option.
38
+
39
+
### Trace comparisons
40
+
41
+
The **`/fsanitize-coverage=trace-cmp`** compiler option instructs the compiler to insert calls to the following functions:
42
+
43
+
```C
44
+
// Before each comparison instruction of the stated size.
Use the **`/fsanitize`** compiler options to enable sanitizers. As of Visual Studio 2019 16.9, the only supported sanitizer is [AddressSanitizer](../../sanitizers/asan.md).
10
+
Use the **`/fsanitize`** compiler options to enable sanitizers.
11
11
12
12
## Syntax
13
13
14
14
> **`/fsanitize=address`**\
15
+
> **`/fsanitize=fuzzer`**\
15
16
> **`/fsanitize-address-use-after-return`**\
16
17
> **`/fno-sanitize-address-vcasan-lib`**
17
18
18
19
## Remarks
19
20
20
-
The **`/fsanitize=address`** compiler option enables [AddressSanitizer](../../sanitizers/asan.md), a powerful compiler and runtime technology to light up [hard-to-find bugs](../../sanitizers/asan.md#error-types).
21
+
The **`/fsanitize=address`** compiler option enables [AddressSanitizer](../../sanitizers/asan.md), a powerful compiler and runtime technology to uncover [hard-to-find bugs](../../sanitizers/asan.md#error-types). Support for the **`/fsanitize=address`** option is available starting in Visual Studio 2019 version 16.9.
21
22
22
-
The **`/fsanitize-address-use-after-return`** and **`/fno-sanitize-address-vcasan-lib`** compiler options, and the [`/INFERASANLIBS` (Use inferred sanitizer libs)](./inferasanlibs.md) and **`/INFERASANLIBS:NO`** linker options offer support for advanced users. For more information, see [AddressSanitizer build and language reference](../../sanitizers/asan-building.md).
23
+
The **`/fsanitize=fuzzer`** compiler option enables experimental support for [LibFuzzer](https://releases.llvm.org/3.8.0/docs/LibFuzzer.html). LibFuzzer is a coverage-guided fuzzing library that can be used to find bugs and crashes caused by user-provided input. We recommended you use **`/fsanitize=address`** with LibFuzzer. This option is useful for fuzzing tools such as OneFuzz. For more information, see the [OneFuzz documentation](https://www.microsoft.com/en-us/research/project/project-onefuzz/) and [OneFuzz GitHub project](https://github.com/microsoft/onefuzz). Support for the **`/fsanitize=fuzzer`** option is available starting in Visual Studio 2022 version 17.0.
24
+
25
+
The **`/fsanitize`** option doesn't allow comma-separated syntax, for example: **`/fsanitize=address,fuzzer`**. These options must be specified individually.
23
26
24
-
The **`/fsanitize`** options are available beginning in Visual Studio 2019 version 16.9.
27
+
The **`/fsanitize-address-use-after-return`**and **`/fno-sanitize-address-vcasan-lib`** compiler options, and the [`/INFERASANLIBS` (Use inferred sanitizer libs)](./inferasanlibs.md) and **`/INFERASANLIBS:NO`** linker options offer support for advanced users. For more information, see [AddressSanitizer build and language reference](../../sanitizers/asan-building.md).
25
28
26
29
### To set the **`/fsanitize=address`** compiler option in the Visual Studio development environment
27
30
@@ -33,6 +36,16 @@ The **`/fsanitize`** options are available beginning in Visual Studio 2019 versi
33
36
34
37
1. Choose **OK** or **Apply** to save your changes.
35
38
39
+
### To set the **`/fsanitize=fuzzer`** compiler option in the Visual Studio development environment
40
+
41
+
1. Open your project's **Property Pages** dialog box.
0 commit comments