Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1618

C++ Rule: Reference types should not be qualified with "const" or "volatile"

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.2
    • Component/s: C++, Rules
    • Labels:
      None

      Description

      void example_1(char p) {
        char & const c = p; // error in Clang 3.8 and GCC 4.8, warning in MSVC
      }
      
      void example_2(char p) {
        typedef char & T;
        const T c = p; // warning in Clang 3.8 [-Wignored-qualifiers], ignored by GCC and MSVC
      }
      

      See https://www.securecoding.cert.org/confluence/display/cplusplus/DCL52-CPP.+Never+qualify+a+reference+type+with+const+or+volatile

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Due:
                Created:
                Updated:
                Resolved: