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

Rule S820 should also check function parameters

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.12
    • Component/s: Rules
    • Labels:
      None

      Description

      Today's compilers allow usage of "implicit int" (and our frontend also), despite the fact that it was removed in C99 standard:

      example.c
      void fun(const x) {
      }
      

      Note that this example doesn't use K&R style of declaration of function parameters due to presence of "const".

      cl /Zs /W4 example.c
      example.c(3): warning C4431: missing type specifier - int assumed. Note: C no longer supports default-int
      

      Note that Microsoft compiler will be silent without "/W4".

      clang-3.7 -fsyntax-only -std=c11 example.c
      example.c:1:16: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
      
      gcc-4.9 -fsyntax-only -std=c11 example.c
      example.c:1:6: warning: type of 'x' defaults to 'int'
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Due:
                Created:
                Updated:
                Resolved: