IBM Support

Code Review ignores rule 5.4 for struc tag with union

Technote (FAQ)


When you use a struct tag with a union reserved word in IBM Rational Test RealTime, why does Code Review not report any violations of rule 5.4?


The rule M5.4 states that, if you use a struct tag after the union reserved word, you violate rule M5.4. However, Code Review does not report this rule's violation.



All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

struct struct_t
uinteger_T uword;
uchar_T ubytes [ 4 ];
} ;
union struct_t my_struct; /* Not Compliant with rule 5.4 */

Code review does report an error on the "my_struct" variable declaration. However, the rule M1.1 yields "the code is not ANSI compliant". This is because the preceding code will not compile. You will get error messages. For example, the Microsoft compiler gives you the following output.

rule_5_4_a.c(23) : error C2011: 'struct_t' : 'struct' type redefinition
rule_5_4_a.c(17) : see declaration of 'struct_t'


When Code Review detects that the code will not compile, you see a rule M1.1 violation. This rule possibly prevents testing of further rules. This is because the C code analyzer might be in an incorrect state to provide all the information for the testing of the rules.

Consider the following guidelines.

  • Enable rule M1.1 always.

  • Verify that the code compiles.

  • Correct all violations to rule M1.1, before you look for violations of other rules.

Related information

Code review rules

Document information

More support for: Rational Test RealTime
Code Review for C

Software version: 7.5,,,,,,, 8.0,,

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1441601

Modified date: 10 December 2012