Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public
Document Table of Contents

guard

Enables control flow protection mechanisms.

Syntax

Linux:

None

Windows:

/guard:keyword

Arguments

keyword

Specifies the control flow protection mechanism. Possible values are:

cf[-]

Tells the compiler to analyze control flow of valid targets for indirect calls and then to insert code at runtime to verify the targets.

To explicitly disable this option, specify /guard:cf-.

cf,nochecks

Tells the compiler to only emit the table of address-taken functions. No control flow checks are performed.

ehcont[-]

Tells the compiler to generate a sorted list of the relative virtual addresses (RVA) of all the valid exception handling continuation targets for a binary.

It enables EH Continuation Guard, which is used during runtime for NtContinue and SetThreadContext instruction pointer validation.

To explicitly disable this option, specify /guard:ehcont-.

Default

OFF

The control flow protection mechanisms are disabled.

Description

This option enables control flow protection mechanisms.

Options /guard:cf, /guard:cf,nochecks, and /guard:ehcont must be passed to both the compiler and linker.

Code compiled using /guard:cf can be linked to libraries and object files that are not compiled using the option.

This option has been added for Microsoft compatibility. Keywords cf and ehcont use the Microsoft implementation.

NOTE:

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

IDE Equivalent

Visual Studio: Code Generation > Control Flow Guard

Eclipse: None

Alternate Options

None