C++: Add some test cases for cpp/wrong-type-format-argument#21421
Open
geoffw0 wants to merge 3 commits intogithub:mainfrom
Open
C++: Add some test cases for cpp/wrong-type-format-argument#21421geoffw0 wants to merge 3 commits intogithub:mainfrom
geoffw0 wants to merge 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new test coverage for cpp/wrong-type-format-argument to reproduce/track a build-mode-none-style failure mode where size_t can be misinterpreted (e.g., as a function pointer type) and yields nonsensical alert messages.
Changes:
- Adds a buildless-style repro involving
size_tandprintfformat specifiers. - Updates the expected test output for
WrongTypeFormatArgumentsaccordingly. - Adds supporting buildless test inputs to exercise the extractor/query behavior under errors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/second.cpp | New/updated repro that exercises the size_t mis-typing scenario in a buildless/error-tolerant extraction context. |
| cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/first.cpp | Provides a plausible size_t typedef for the multi-TU scenario. |
| cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/tests.c | Additional buildless/error-handling coverage for format argument typing. |
| cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/tests2.c | Additional wrapper/multiple-definition scenario coverage. |
| cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/WrongTypeFormatArguments.expected | Updates expected alerts to capture the reproduced behavior. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add some test cases for
cpp/wrong-type-format-argument, showing how we can apparently mistakesize_tfor a function pointer type in some circumstances. This is based on an issue I've seen in the wild (in a build-mode-none database).The typedef for
myFunctionPointerTypeis a compiler error as written, but we're simulating a situation where the definition ofsize_tis present, but invisible to the extractor due to BMN. I think the underlying issue may be something to do with how we handle this error case - though there are a few ways the problem could be addressed in the query if necessary.Note that the query is very permissive, amongst other things it already allows integer signed-ness mismatches - so I'm of the opinion that using
%zufor a signedsize_tshould not be flagged. Regardless, the message claiming thesize_tis type..(*)(..)is a problem, unless I'm missing something here.