`RULE-21-15`: Improve detection of compatible types

Open
#573 0 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Assessment

This issue has not been assessed yet.

Description

Difficulty-Medium false positive/false negative Impact-Medium Standard-MISRA-C
Affected rules
  • RULE-21-15
Description

The query for this rule is currently too strict - it requires the types be identical (after stripping specifiers), instead of compatible. For example, it does not allow a combination of pointers and arrays, or array types with different sizes, or types which are compatible but not identical (e.g. signed int and int.

Example
void example_function(int i1[80], int *i2, int i3[10], signed int *i4) {
  memcpy(i1,i2,1); // COMPLIANT[FALSE_POSITIVE]
  memcpy(i1,i3,1); // COMPLIANT[FALSE_POSITIVE]
  memcpy(i2,i3,1); // COMPLIANT[FALSE_POSITIVE]
  memcpy(i2,i4,1); // COMPLIANT[FALSE_POSITIVE]
}
Dominant language
CodeQL
Stars
227
Forks
82
Avg merge
6d 7h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql-coding-standards

All issues in github/codeql-coding-standards

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.