-
Notifications
You must be signed in to change notification settings - Fork 62
Implement package FloatingPoint #887
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
base: main
Are you sure you want to change the base?
Implement package FloatingPoint #887
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request implements the FloatingPoint package by refactoring the DIR‑4‑15 query to be shared with DIR‑0‑3‑1 and updating test cases to reflect improved floating point guard behavior.
- Added cosine and sine declarations in the standard-library header.
- Updated change notes to document modifications in infinity/NaN detection.
- Updated test cases for misuse of NaN and infinite floating point values with revised compliance annotations.
Reviewed Changes
Copilot reviewed 15 out of 31 changed files in this pull request and generated no comments.
File | Description |
---|---|
cpp/common/test/includes/standard-library/math.h | Added overloads for cos and sin to support floating point operations. |
change_notes/2025-04-14-update-infinity-nan-detection.md | Documented the updated behavior for NaN and infinity detection. |
c/common/test/rules/misuseofnanfloatingpointvalue/test.c | Introduced tests for casting and comparisons involving NaN values. |
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c | Updated test cases with revised compliance annotations for infinite and NaN scenarios. |
Files not reviewed (16)
- c/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.expected: Language not supported
- c/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.ql: Language not supported
- c/common/test/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.expected: Language not supported
- c/common/test/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.ql: Language not supported
- c/misra/src/rules/DIR-4-15/PossibleMisuseOfUndetectedInfinity.ql: Language not supported
- c/misra/src/rules/DIR-4-15/PossibleMisuseOfUndetectedNaN.ql: Language not supported
- c/misra/test/rules/DIR-4-15/PossibleMisuseOfUndetectedInfinity.testref: Language not supported
- c/misra/test/rules/DIR-4-15/PossibleMisuseOfUndetectedNaN.testref: Language not supported
- cpp/common/src/codingstandards/cpp/FloatingPoint.qll: Language not supported
- cpp/common/src/codingstandards/cpp/RestrictedRangeAnalysis.qll: Language not supported
- cpp/common/src/codingstandards/cpp/exclusions/cpp/FloatingPoint.qll: Language not supported
- cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll: Language not supported
- cpp/common/src/codingstandards/cpp/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.qll: Language not supported
- cpp/common/src/codingstandards/cpp/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.qll: Language not supported
- cpp/common/test/includes/standard-library/cmath: Language not supported
- cpp/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.expected: Language not supported
Comments suppressed due to low confidence (6)
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:36
- The compliance annotation for casting a NaN value (for (int)l5 and similarly for (int)l6) now indicates COMPLIANT, which differs from the misuseofnanfloatingpointvalue tests. Please verify that this change reflects the intended behavior for infinite value misuse tests.
(int)l5; // COMPLIANT: Casting NaN to int
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:201
- The annotation change for castToIntToFloatToInt with a NaN input now marks it as COMPLIANT. Please confirm this accurately reflects the intended behavior in the context of infinite floating point misuse.
castToIntToFloatToInt(0.0 / 0.0); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:209
- The expected compliance for casting middleNaN is now COMPLIANT. Please verify that this change aligns with the overall intended query behavior compared to similar tests in misuseofnanfloatingpointvalue.
castToInt(middleNaN); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:211
- Marking addNaNThenCastToInt with middleNaN as COMPLIANT now differs from previous non-compliant annotations in related tests. Please ensure this change is intentional and consistent with the intended behavior for infinite misuse scenarios.
addNaNThenCastToInt(middleNaN); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:161
- The false negative annotation for (int)pow(2, p1) indicates a possible detection gap for infinity. It would be beneficial to confirm that this behavior is expected within the updated query logic.
(int)pow(2, p1); // NON_COMPLIANT[False negative]: likely to be Infinity
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:198
- The false negative label for addOneThenCastToInt with an infinite input suggests a potential oversight in detecting misuse. Please double-check that this annotation is correct and aligns with the overall test expectations.
addOneThenCastToInt(1.0 / 0.0); // NON_COMPLIANT[False negative]
Description
Move
DIR-4-15
to be a shared query to supportDIR-0-3-1
Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
DIR-0-3-1
DIR-4-15
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.