-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressA false positive or false negative report which is expected to take <1 day effort to addressImpact-Highfalse positive/false negativeAn issue related to observed false positives or false negatives.An issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding StandardsIssue reported by an end user of CodeQL Coding Standards
Description
Affected rules
M6-5-5
Description
M6-5-5
identifies cases where a loop control variable is modified in the condition of a loop. It identifies two kinds of modifications: direct modification, and indirect modification - where a reference to the loop counter variable escapes the local scope, and could be modified. We currently assume that any reference that escapes the scope could be modified, but we should factor in whether the escaping function is const/non-const.
Specifically, we need to use isAddressOfAccessNonConst()
instead of isAddressOfAccess()
here:
loopControlVariableAccess.isAddressOfAccess() |
Example
void loop(std::vector v) {
std::vector<int>::iterator first = v.begin();
std::vector<int>::iterator last = v.end();
for (; first != last; first++) { // call to operator!= passes a reference to first
}
}
Metadata
Metadata
Assignees
Labels
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressA false positive or false negative report which is expected to take <1 day effort to addressImpact-Highfalse positive/false negativeAn issue related to observed false positives or false negatives.An issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding StandardsIssue reported by an end user of CodeQL Coding Standards
Type
Projects
Status
Done