Skip to content
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

Can Infer spot dead code in C? #1837

Closed
u201111476 opened this issue Jun 5, 2024 · 2 comments
Closed

Can Infer spot dead code in C? #1837

u201111476 opened this issue Jun 5, 2024 · 2 comments

Comments

@u201111476
Copy link

I have a file named main.c,whose content is as following:

#include <stdio.h>
int main()
{
if(false)
{
printf("skip!\n");
}
return 0;
}

then I use infer capture -- clang -c main.c and infer analyze,there is no dead code in the result though the printf will never execute. What should I do to let Infer report this dead code?

@skcho
Copy link
Contributor

skcho commented Jun 5, 2024

Infer detects dead store, but not general dead code as above. In addition, the liveness checker does simple data flow analysis, so does not try to understand the boolean condition that is always evaluated to true or false.
https://fbinfer.com/docs/next/all-issue-types#dead_store

@skcho skcho closed this as completed Jun 5, 2024
@u201111476
Copy link
Author

Does Infer plan to release a next version to support dead code check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants