Details

    • Type: Language-Specification
    • Status: Active
    • Resolution: Unresolved
    • Labels:
      None
    • Impact:
      Unknown 'null' severity
    • Likelihood:
      Unknown 'null' severity
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended

      Description

      Noncompliant Code Example

      int example(int i) {
        int result = static_cast<int>(i + 42); // Noncompliant
        return (int) result; // Noncompliant
      }
      

      Compliant Solution

      int example(int i) {
       int result = i + 42;
       return result;
      }
      

      Exceptions

      In some rare cases, redundant cast might be justifiable. For example, when casting from platform dependant type; your cast might be redundant on one platform but not on the others.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            evgeny.mandrikov Evgeny Mandrikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated: