C and C++


LANG.TYPE.UNION : Union Type

Summary

A declaration involves a union type.

Properties

Class Name Union Type
Significance style
Mnemonic LANG.TYPE.UNION
Categories
MisraC2023 MisraC2023:19.2 The union keyword should not be used
Misra2012 Misra2012:19.2 The union keyword should not be used
Misra2004 Misra2004:18.4 Unions shall not be used
AUTOSARC++14 AUTOSARC++14:A9-5-1 Unions shall not be used.
MisraC++2008 MisraC++2008:9-5-1 Unions shall not be used.
MisraC++2023 MisraC++2023:12.3.1 The union keyword shall not be used
JSF++ JSF++:153 Unions shall not be used.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Union Type"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

union utag {int i; double d;};           /* 'Union Type' warning issued here */
  
union {int i; double d;} anonu ;         /* 'Union Type' warning issued here */

typedef union A {int i; double d;} B;    /* 'Union Type' warning issued here */

void f_arg (union {int i; double d;} y){ /* 'Union Type' warning issued here */
  return;
}

union {int i; double d;} f_ret (void);   /* 'Union Type' warning issued here */

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.