hisl_0029: Usage of Assignment blocks
R2026bInitialize array fields before first use in the Assignment block to avoid undesirable results in generated code
Usage: High-Integrity System Modeling
Guideline ID: hisl_0029
Rules
| hisl_0029: Usage of Assignment blocks |
|---|
|
To support robustness of generated code, when using the Assignment block, initialize array fields before their first use. Rationale Avoid undesirable results in generated code. Verification Check usage of Assignment blocks (Simulink Check) Example — Correct Initialization input Y0 when block is not used iteratively.
Example — Correct Initialize array fields when block is used iteratively.
Example — Incorrect No initialization input Y0 when block is not used iteratively.
|
Tips
If the output vector of the Assignment block is not initialized with an input to the block, elements of the vector might not be initialized in the generated code.
When the Assignment block is used iteratively and array fields are assigned during one simulation time step, you do not need initialization input to the block.
Accessing uninitialized elements of block output can result in unexpected behavior.
For a partial write operations, maintain a persistent output buffer (for example, see cgsl_0408: Partial data send for component deployment).
Industry Standards
IEC 61508-3, Table A.3 (3) 'Language subset'
IEC 61508-3, Table A.4 (3) 'Defensive programming'
IEC 61508-3, Table A.3 (2) 'Strongly typed programming language'
IEC 62304, 5.5.3 - Software Unit acceptance criteria
ISO 26262–6, Table 1(b) 'Use of language subsets'
ISO 26262–6, Table 1(d) 'Use of defensive implementation techniques'
EN 50128, Table A.4 (11) 'Language Subset'
EN 50128, Table A.3 (1) 'Defensive Programming'
EN 50128, Table A.4 (8) 'Strongly Typed Programming Language'
EN 50657, Table A.4 (11) 'Language Subset'
EN 50657, Table A.3 (1) 'Defensive Programming'
EN 50657, Table A.4 (8) 'Strongly Typed Programming Language'
EN 50716, Table A.3 (1) 'Defensive Programming'
DO-331, Section MB.6.3.2.g – 'Algorithms are accurate'
MISRA C:2012, Rule 9.1
MISRA C:2023, Rule 9.1
EXP33-C. Do not read uninitialized memory
![Simulink model with a constant [0 0 0] connected to Y0 input and two inports connected to the U and Idx inputs of a 1-D Assignment block.](hisl_0029_rec1.png)




![Generated code declaring the output array without initialization, leaving element [1] uninitialized before it is read.](hisl_0029_notrec_code.png)