/fsanitize (Enable sanitizers)

Use the /fsanitize compiler options to enable sanitizers. As of Visual Studio 2019 16.9, the only supported sanitizer is AddressSanitizer.

Syntax

/fsanitize=address
/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 light up hard-to-find bugs.

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.

The /fsanitize options are available beginning in Visual Studio 2019 version 16.9.

To set the /fsanitize=address compiler option in the Visual Studio development environment

  1. Open your project's Property Pages dialog box.

  2. Select the Configuration Properties > C/C++ > General property page.

  3. Modify the Enable Address Sanitizer property. To enable it, choose Yes (/fsanitize=address).

  4. Choose OK or Apply to save your changes.

To set the advanced compiler options

  1. Open your project's Property Pages dialog box.

  2. Select the Configuration Properties > C/C++ > Command Line property page.

  3. Modify the Additional Options property to set /fsanitize-address-use-after-return or /fno-sanitize-address-vcasan-lib.

  4. Choose OK or Apply to save your changes.

To set this compiler option programmatically

See also

MSVC compiler options
MSVC compiler command-line syntax
/INFERASANLIBS (Use inferred sanitizer libs)
AddressSanitizer overview
AddressSanitizer known issues
AddressSanitizer build and language reference