Stateflow and Stateflow Coder Release Notes    

Compound Assignment Operators with Fixed-Point Data Can Produce Incorrect Results

There is a known problem using fixed-point data with compound assignment operators (+=, -=, *=, /=) in Stateflow action language. In some circumstances, the intermediate operation (+, -, *, /) is performed using an inappropriate data type, that can lead to unexpected overflow or rounding errors (and inefficient code).

Stateflow detects most of these error conditions (but not all of them) during code generation, and generates an error message like the following:

Because Stateflow cannot detect all these error conditions, you must work around the problem by separating the operation and the assignment from a compound assignment. For example, replace the compound assignment

with the simple assignment

There is no problem with compound assignment as long as both sides of the assignment do not contain fixed-point data.


  Known Software and Documentation Problems Stateflow 4.1 and Stateflow Coder 4.1 Release Notes