Why is this an issue?
The use of unions to access an object in different ways may result in the data being misinterpreted. Therefore, this rule prohibits the use of
unions for any purpose.
Noncompliant code example
union U1 { // Noncompliant
float j;
int i;
};
Resources
- MISRA C:2004, 18.4 - Unions shall not be used.
- MISRA C++:2008, 9-5-1 - Unions shall not be used.
- MISRA C:2012, 19.2 - The union keyword should not be used