-
Notifications
You must be signed in to change notification settings - Fork 1.7k
False positive in C/C++ dead code detection #19399
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
Comments
Hi @Faycal572, Unfortunately I cannot reproduce the problem you're reporting. I've tried is to create a database as follows:
When I then run your query on that database, I do not see the problem you're reporting. Could you provide instructions on how to reproduce the issue? |
Hi, thanks for your answer. The code where I observe this false positive comes from an internal tool developed by my company, and unfortunately I cannot share the full project for confidentiality reasons. However, the root cause seems clear: I have seen this false positive in several similar cases. Thanks again! |
Thanks for your answer,
That's an incorrect diagnosis. First, I suspect there's some deeper problem with the quality of your database, but given that you cannot share any reproducer, this is impossible for me to diagnose any further here. However, given our license and the fact that you cannot share any further details here will mean that your company is a paying customer, the way forward here would be to open a support ticket with GitHub support as explained here https://docs.github.com/en/support/contacting-github-support/creating-a-support-ticket. That will allow for a more private way of sharing data. |
Description of the false positive
The query for unreachable code (BasicBlock where not bb1.isReachable()) incorrectly detects live code as dead code in C/C++.
Specifically, in the function Tcl_TranslateFileName, it incorrectly flags a for loop that is clearly reachable and executed in normal control flow.
tclPlatform is a global variable, so the condition if (tclPlatform == TCL) can be true at runtime, making the code reachable.
This leads to several false positives in real codebases.
Code samples or links to source code
Here is an example:
Query used to detect unreachable blocks:
The block:
is wrongly reported as unreachable (dead code), but it is active and necessary to correctly translate file paths.
This false positive happens in several similar real-world cases, and makes the dead code detection query unreliable.
The text was updated successfully, but these errors were encountered: