主要内容

Numeric errors (-sanitizer-selection numeric)

R2026b

Enable detection of numeric errors at runtime

Since R2026b

Description

Specify whether the sanitizer detects numeric computation errors at runtime. Numeric errors include division by zero, integer and floating-point overflow, shift operation errors, type conversion overflows, array out-of-bounds access, null pointer arithmetic, standard library numeric errors, and assertion failures.

Set Option

Set the option using one of these methods:

  • Polyspace Platform user interface (desktop products only): In your project configuration, on the Testing and Profiling tab, select the Sanitizer node, select Select by category, and then select or clear this option.

  • Command line: Use the option -sanitizer-selection and include numeric in the comma-separated list. See Command-Line Information.

  • Python® API: Set the Numeric property in the testing and profiling configuration. See polyspace.project.TestConfiguration.

  • TOML configuration file (.toml.pscfg) — Use the key Numeric in the [SanitizerOptions] table. For example:

    [SanitizerOptions]
    Numeric = true

Why Use This Option

Use this option to detect numeric computation errors in your code at runtime. The sanitizer instruments your source code to check for errors such as:

  • Division by zero (integer and floating-point)

  • Integer and floating-point overflow and underflow

  • Invalid shift operations

  • Type conversion overflows

  • Array out-of-bounds access

  • Null pointer arithmetic

  • Standard library numeric errors

  • Assertion failures

Settings

On (default)

The sanitizer detects numeric errors at runtime.

Off

The sanitizer does not detect numeric errors.

Dependencies

This option is available only when you select Select by category as the sanitizer selection mode.

Command-Line Information

The command-line workflow for setting this option depends on your workflow.

  • If you build your source and tests using a Polyspace Platform Project — Once you set this option in the project using the Polyspace Platform user interface, you cannot override or modify this option using the polyspace-test command.

  • If you build your sources and xUnit tests using your own toolchain — Specify this option to the polyspace-code-profiler command.

Parameter: -sanitizer-selection
Value: Include numeric in comma-separated list of error categories
Default: on
Example: polyspace-code-profiler -instrument -instrum-dir instrumFolder -sanitizer -sanitizer-selection numeric,memory -- compileCommand

Version History

Introduced in R2026b