reportBinaryExpressions
This report is especially relevant for m-code that will be used for code generation.
Generated code does not enforce the order of evaluation in expressions. For most expressions, the order of evaluation is not significant. For expressions that have side effects, the generated code might produce the side effects in a different order from the original MATLAB code.
This report lists all binary expressions for which the order of evaluation might matter.
For this report, an expression is a binary expression if it uses a binary operator (+, -, >, >=, &, &&, :, etc.).
An expression will be reported by reportBinaryExpressions if any of these are met:
-
A function is called on both sides of the operator.
-
A function is called on one side of the operator and a relevant variable is accessed on the other side of the operator. Relevant variables are:
- Handle objects
- Persistent variables
- Global variables
If a variable is accessed for which the datatype could not be reliably obtained,
it is also considered a relevant variable when Report violations when not entirely sure described in section Preferences is set to true.
The data types of variables are unknown for example for the inputs of the main function, or outputs of user-defined function calls.
Disabling the preference may lead to fewer false positives being reported.