← 返回首页
Fix FPs for unsigned operations in `INT30-C` and `RULE-8-20-1` by mbaluda · Pull Request #1140 · github/codeql-coding-standards · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .cpp  (1) .md  (1) .qll  (1) All 4 file types selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
  • c/common/test/rules/unsignedoperationwithconstantoperandswraps
    • test.c
  • change_notes
  • cpp/common
    • src/codingstandards/cpp/rules/unsignedoperationwithconstantoperandswraps
    • test/rules/unsignedoperationwithconstantoperandswraps
      • test.cpp
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ void test_sub_postcheck(unsigned int i1, unsigned int i2) {
if (i1 > i2) {
// handle error
}
}

void test_mod_rem(unsigned int i1, unsigned int i2) {
i1 / i2; // COMPLIANT - exception 2
i1 /= i2; // COMPLIANT - exception 2
i1 % i2; // COMPLIANT - exception 2
i1 %= i2; // COMPLIANT - exception 2
}
Comment thread
Copilot marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions change_notes/2026-06-18-fix-fp-misra-c++-8-20-1.md
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- `INT30-C` - `UnsignedIntegerOperationsWrapAround.ql`:
- Fixed false positives for `/=` and `%=` assignments.
- `RULE-8-20-1` - `UnsignedOperationWithConstantOperandsWraps.ql`:
- Fixed false positives for `/=` and `%=` assignments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ query predicate problems(InterestingOverflowingOperation op, string message) {
// Permitted by exception 3
not op instanceof LShiftExpr and
// Permitted by exception 2 - zero case is handled in separate query
not op instanceof DivExpr and
not op instanceof RemExpr and
not op instanceof DivOrRemOperation and
message =
"Operation " + op.getOperator() + " of type " + op.getType().getUnderlyingType() + " may wrap."
}
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ void test_sub_postcheck(unsigned int i1, unsigned int i2) {
if (i1 > i2) {
// handle error
}
}

void test_mod_rem(unsigned int i1, unsigned int i2) {
i1 / i2; // COMPLIANT - exception 2
i1 /= i2; // COMPLIANT - exception 2
i1 % i2; // COMPLIANT - exception 2
i1 %= i2; // COMPLIANT - exception 2
}
Comment thread
Copilot marked this conversation as resolved.
Show resolved Hide resolved
Loading
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.