Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RULE-11-3: Permit cast to pointer-to-void #317

Closed
lcartey opened this issue Jun 28, 2023 · 3 comments · Fixed by #744
Closed

RULE-11-3: Permit cast to pointer-to-void #317

lcartey opened this issue Jun 28, 2023 · 3 comments · Fixed by #744
Assignees
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-High user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@lcartey
Copy link
Collaborator

lcartey commented Jun 28, 2023

Affected rules

  • RULE-11-3
  • RULE-11-4
  • RULE-11-5
  • RULE-11-7

Description

The rule states that "a cast shall not be performed between a pointer to object type and a pointer to a different object type". However, void isn't a different object type. Rule 11.5 handles pointer-to-void, prohibiting casting from pointer-to-void, but permitting casting to pointer-to-void.

Update: this has been determined to be a problem specifically with const void * and other specified void pointers.

Example

uint32_t *p32;
void *p;
p = p32; // Compliant
@lcartey lcartey added the false positive/false negative An issue related to observed false positives or false negatives. label Jun 28, 2023
@lcartey lcartey added Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address user-report Issue reported by an end user of CodeQL Coding Standards Impact-High and removed Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address labels Nov 20, 2023
@lcartey lcartey self-assigned this Jan 14, 2024
@ravikprasad
Copy link

Can this be prioritized and incorporated in the current MISRA C 2023 work?

@lcartey lcartey moved this from Assigned to In Progress in Coding Standards Public Development Board Oct 11, 2024
@lcartey
Copy link
Collaborator Author

lcartey commented Oct 11, 2024

After further investigation, the problem with this query is that it doesn't exclude const void pointers - the determination of a whether a pointer is a pointer-to-object is confused by the presence of specifiers. This is not limited to RULE-11-3 - it also affects RULE-11-4, RULE-11-5 & RULE-11-7.

@lcartey
Copy link
Collaborator Author

lcartey commented Oct 11, 2024

PR opened to address this issue:
#744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-High user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

Successfully merging a pull request may close this issue.

2 participants