Menu

Cppcheck 2.18 - False Positive - Misra 5.8

Jan Joseph
2025-10-07
2025-10-08
  • Jan Joseph

    Jan Joseph - 2025-10-07

    Cppcheck is triggering 5.8 for struct member with the same name as external identifier in a erratic manner (sometimes it throws the error, sometimes it doesn't)

    struct A { int size; };
    extern struct B size;
    

    Since the vars are in different namespaces this should be MISRA 5.8 compliant.

     
  • Jan Joseph

    Jan Joseph - 2025-10-08

    Sorry, I forgot to mention the CLI command

    cppcheck --enable=all \
    --inconclusive \
    --std=c99 \
    --addon=misra.json \
    --language=c \
    --platform=native \
    --inline-suppr \
    --verbose \
    --check-level=exhaustive \
    --project=compile_commands.json \
    --suppressions-list=suppressions.txt \
    --xml --xml-version=2
    

    with misra.json being

    {
      "script": "./misra.py",
      "args": [
        "--rule-texts=./misra.txt"
      ]
    }
    

    Since the actual file structure is a bit complicated I tried to reproduce the behaviour in a pseudo code.
    file_A.h

    struct A { int size; };
    

    file_B.h

    extern struct B size;
    

    While struct B is defined in file_C.h with the error coming up in the above mentioned lines.
    Please let me know if any info is missing. Thanks!

     

    Last edit: Jan Joseph 2025-10-08

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.