Developer Guide and Reference

Contents

Pointer Checker Feature Summary

The pointer checker is not supported on
macOS*
systems.
The pointer checker provides a number of related elements, summarized in the following table.
Element
Description
Compiler Options:
[Q]check-pointers
Enables the pointer checker and adds the associated libraries. This compiler option enables checking of all indirect accesses through pointers and accesses to arrays.
The possible option keywords are [
none
|
write
|
rw
], where:
  • none
    : Disables the pointer checker (default).
  • write
    : Checks bounds for only writes through pointers.
  • rw
    : Checks bounds for reads and writes through pointers.
If the compiler determines that an access is safe during optimization, then the compiler removes the pointer checking code.
[Q]check-pointers-dangling
Enables checking for dangling pointer references.
The possible option keywords are [
none
|
heap
|
stack
|
all
], where:
  • none
    : Disables checking for dangling pointer references (default).
  • heap
    : Checks for dangling pointer references on the heap.
  • stack
    : Checks for dangling pointer references on the stack.
  • all
    : Checks for dangling pointer references on both the heap and the stack.
To use this option, you must also use the
[Q]check-pointers
compiler option.
This option cannot be used with
[Q]check-pointers-mpx
.
[Q]check-pointers-undimensioned
Enables the checking of bounds for arrays without dimensions.
To use this option, you must also use the
[Q]check-pointers
compiler option.
[Q]check-pointers-narrowing
Determines whether the compiler enables or disables the narrowing of pointers to structure fields. Narrowing restricts a field pointer so that it can only legally point to that field.
Enables or disables the compiler narrowing of pointers to structure fields.
The default is enabled for narrowing pointer references. Disabling this feature can improve Pointer Checker compatibility with non-ANSI compliant code. To disable the narrowing of pointers to structure fields, specify the negative form of the option.
To use this option, you must also use the
[Q]check-pointers
compiler option.
check-pointers-mpx, Qcheck-pointers-mpx
Determines whether the compiler checks bounds for memory access through pointers on processors supporting Intel® Memory Protection Extensions (Intel® MPX). It enables checking of all indirect accesses through pointers, and all array accesses.
Specifies what type of bounds checking occurs. The possible option keywords are [
none
|
write
|
rw
], where:
  • none
    : Disables the pointer checker (default).
  • write
    : Checks bounds for only writes through pointers.
  • rw
    : Checks bounds for reads and writes through pointers.
The compiler may optimize these checks away when it can determine that an access is safe.
This option cannot be used with
[Q]check-pointers-dangling
.
If you specify option
[Q]check-pointers
along with option
[Q]check-pointers-mpx
,
[Q]check-pointers-mpx
takes precedence.
On supported Windows* target platforms, MPX instructions can also be accessed using MPX intrinsic functions and the
__declspec(mpx)
feature. For more details, please see the Intel Memory Protection Extensions Enabling Guide (https://software.intel.com/sites/default/files/managed/9d/f6/Intel_MPX_EnablingGuide.pdf).
Intrinsics:
void * __chkp_lower_bound(void **)
Returns the lower bound associated with the pointer.
void * __chkp_upper_bound(void **)
Returns the upper bound associated with the pointer.
void * __chkp_kill_bounds(void *p)
Removes the bounds information to allow the pointer specified in the argument to access all memory. Use this function for a pointer from a non-enabled module that will be used in an enabled module where you cannot determine the bounds of the pointer.
The function ensures that the pointer created from a non-enabled module does not inherit the bounds from another pointer that was in the same memory address.
The return value is a pointer without bounds information.
void * __chkp_make_bounds(void *p, size_t size)
Creates new bounds information within the allocated memory address for the pointer in the argument, replacing any previously associated bounds information. The new bounds are:
p = __chkp_make_bounds(q, size) // lower_bound(p) = (char *)q // upper_bound(p) = lower_bound(p) + size
Reporting Function:
void __chkp_report_control(__chkp_report_option_t option, __chkp_callback_t callback)
Determines how errors are reported.
Enumeration:
__chkp_report_option_t
Controls how out-of-bounds error are reported. This enumeration is declared in the header file
chkp.h
.
Environment Variable:
INTEL_CHKP_REPORT_MODE
Changes the pointer checker reporting mode at runtime.
See