Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Legacy Key:
      Union
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      15min
    • MISRA C 2004:
      18.4
    • MISRA C 2012:
      19.2
    • MISRA C++ 2008:
      9-5-1
    • PC-Lint:
      9018

      Description

      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;
      };
      

      See

      • 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

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4364 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: