Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

fsanitize

Enables the specified code sanitizer to detect certain issues at runtime.

Syntax

Linux:

-fsanitize=sanitizer

Windows:

/fsanitize=sanitizer

Arguments

sanitizer

Specifies the code sanitizer to use. You can only specify one sanitizer. Possible values are:

address

Detects buffer overflows/underflows (Linux and Windows) and memory leaks (Linux only).

memory (Linux only)

Detects uninitialized variables. The memory sanitizer requires all code (library code that is linked, either dynamically or statically) to be sanitized, or you may encounter false positives either in user code or in library code.

This setting is the same as specifying option -check uninit.

thread (Linux only)

Detects data races in a threaded program.

Default

OFF

The sanitizers follow default heuristics at runtime.

Description

This option enables the specified code sanitizer to detect certain issues at runtime.

Option fsanitize is especially useful when you want to make sure that your program is free of the various issues detected by the sanitizers, or when your program behaves erratically, and you cannot pinpoint the issue by inspecting the source code or by using a debugger.

When running a thread-sanitized OpenMP program, please set the environment variable "OMP_TOOL_LIBRARIES='libarcher.so'" to get more accurate data race detections.

You should not specify fsanitize when building production code.

To ensure that the required runtime libraries are linked and correctly initialized, specify option -fsanitize in the link command if any part of the object file is compiled with this option.

NOTE:

This option only applies to host compilation. When offloading is enabled, it does not impact device-specific compilation.

IDE Equivalent

None

Alternate Options

None