Details

    • Message:
      Replace this digraph 'xxx' by its equivalent 'yyy'.
    • Default Severity:
      Blocker
    • Impact:
      High
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      DigraphUsage
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • MISRA C++ 2008:
      2-5-1
    • PC-Lint:
      9102

      Description

      The use of digraphs may not meet developer expectations.

      The digraphs are:

      • <%
      • %>
      • <:
      • :>
      • %:
      • %:%:

      Noncompliant Code Example

      template <typename T>
      class A
      {
        public:
          template<int32_t i>
          void f2();
      };
      
      void f(A<int32_t> * a<:10:>)    /* Noncompliant - usage of '<:' instead of '[' and ':>' instead of ']' */
      <%                              /* Noncompliant - usage of '<%' instead of '{' */
        a<:0:>->f2<20>();             /* Noncompliant - usage of '<:' and ':>' */
      %>                              /* Noncompliant - usage of '%>' instead of '}' */
      

      Compliant Solution

      /* ... */
      
      void f(A<int32_t> * a[10])      /* Compliant */
      {                               /* Compliant */
        a[0]->f2<20>();               /* Compliant */
      }                               /* Compliant */
      

      See

      • MISRA C++:2008, 2-5-1 - Digraphs should not be used.

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4357 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: