/fsanitize
(Enable sanitizers)
Use the /fsanitize
compiler options to enable sanitizers.
Syntax
/fsanitize=address
/fsanitize=fuzzer
/fsanitize-address-use-after-return
/fno-sanitize-address-vcasan-lib
Remarks
The /fsanitize=address
compiler option enables AddressSanitizer, a powerful compiler and runtime technology to uncover hard-to-find bugs. Support for the /fsanitize=address
option is available starting in Visual Studio 2019 version 16.9.
The /fsanitize=fuzzer
compiler option enables experimental support for LibFuzzer. 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 and OneFuzz GitHub project. Support for the /fsanitize=fuzzer
option is available starting in Visual Studio 2022 version 17.0.
The /fsanitize
option doesn't allow comma-separated syntax, for example: /fsanitize=address,fuzzer
. These options must be specified individually.
The /fsanitize-address-use-after-return
and /fno-sanitize-address-vcasan-lib
compiler options, and the /INFERASANLIBS
(Use inferred sanitizer libs) and /INFERASANLIBS:NO
linker options offer support for advanced users. For more information, see AddressSanitizer build and language reference.
To set the /fsanitize=address
compiler option in the Visual Studio development environment
Open your project's Property Pages dialog box.
Select the Configuration Properties > C/C++ > General property page.
Modify the Enable Address Sanitizer property. To enable it, choose Yes (/fsanitize=address).
Choose OK or Apply to save your changes.
To set the /fsanitize=fuzzer
compiler option in the Visual Studio development environment
Open your project's Property Pages dialog box.
Select the Configuration Properties > C/C++ > General property page.
Modify the Enable Fuzzer property. To enable it, choose Yes (/fsanitize=fuzzer).
Choose OK or Apply to save your changes.
To set the advanced compiler options
Open your project's Property Pages dialog box.
Select the Configuration Properties > C/C++ > Command Line property page.
Modify the Additional Options property to set /fsanitize-address-use-after-return or /fno-sanitize-address-vcasan-lib.
Choose OK or Apply to save your changes.
To set this compiler option programmatically
- See AdditionalOptions.
See also
MSVC compiler options
MSVC compiler command-line syntax
/INFERASANLIBS
(Use inferred sanitizer libs)
/fsanitize-coverage
(Configure sanitizer coverage)
AddressSanitizer overview
AddressSanitizer known issues
AddressSanitizer build and language reference