Disable Support for Integer Overflow or Nonfinites
The code generator produces supporting code for these situations:
The result of an integer operation falls outside the range that a data type can represent, known as integer overflow.
An operation generates nonfinite values (
If you know that these situations do not occur, to reduce the size of the generated code and increase its speed, you can suppress generation of the supporting code. However, if you suppress generation of the supporting code and one of these situations occurs, the behavior of the generated code might not match the behavior of the original MATLAB® code.
Disable Support for Integer Overflow
By default, the code generator produces code to handle integer overflow. Overflows saturate to either the minimum or maximum value that the data type can represent. If you know that your code does not depend on integer overflow support, to improve performance, you can disable the generation of the code that handles integer overflow. To disable integer overflow support:
In a code generation configuration object for MEX or standalone code (static library, dynamically linked library, or executable program), set the
In the MATLAB Coder™ app, set Saturate on integer overflow to
Do not disable support for integer overflow unless you know that your code does not depend on it. If you disable the support and run-time checking is enabled, the generated code produces an error for integer overflow. If you disable integer overflow support and also disable run-time checking, the behavior for integer overflow is undefined. Most C compilers wrap on overflow.
To check whether your code depends on integer overflow support:
Disable integer overflow support.
Enable checks to detect integer overflow at run time.
For MEX, enable integrity checking. See Control Run-Time Checks.
For standalone code (static library, dynamically linked library, or executable program), enable run-time checks. See Generate Standalone C/C++ Code That Detects and Reports Run-Time Errors.
Run the generated code over the full range of input values. If the generated code detects integer overflow, it produces an error.
Disable Support for Nonfinite Numbers
By default, for standalone code (static library, dynamically linked library, or
executable program), the code generator produces code to handle nonfinite numbers
NaN). If you know that your code
does not depend on nonfinite number support, to improve the
performance of the generated code, you can disable
the support. To disable nonfinite support:
In a code generation configuration object, set the
In the MATLAB Coder app, set Support nonfinite numbers to
If you disable nonfinite support, test that your generated code behaves as expected.