`RULE-6-8-4`: FN for `*this` returning member

Open
#1,122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp
Domain
devtools

Research direction

Start with MembersReturningObject and getASubobjectAccessOfPointee, then compare their behavior with MembersReturningSubObject for the provided C++ example. Check how address and reference returns are distinguished and add focused coverage for the dereferenced this case. Done means RULE-6-8-4 reports the example without duplicating results.

Written by the indexing model from the issue text.

Description

Difficulty-Medium false positive/false negative false-negative Impact-Low
Affected rules
  • RULE-6-8-4
Description

does not find pointer dereferences for this in member functions.

likely need to extend MembersReturningObject to use getASubobjectAccessOfPointee but right now that duplicates results with MembersReturningSubObject unless other checks are applied to make sure the return is an address or reference

getASubobjectAccessOfPointee would also need to be more thoroughly tested in this case

Example

struct A {
  int a;
  A &getstructbad2() { return *this; } // NON_COMPLIANT[FALSE_NEGATIVE]
};

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

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.