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

DeadCode: Only consider a line dead if it is dead in every compilation #715

Closed
lcartey opened this issue Sep 26, 2024 · 0 comments · Fixed by #717
Closed

DeadCode: Only consider a line dead if it is dead in every compilation #715

lcartey opened this issue Sep 26, 2024 · 0 comments · Fixed by #717
Assignees
Labels
Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium

Comments

@lcartey
Copy link
Collaborator

lcartey commented Sep 26, 2024

Affected rules

  • M0-1-9
  • RULE-2-2

Description

When intercepting a build we may see the same file be compiled multiple times in different contexts. When this happens, CodeQL effectively creates an internal "copy" of the analyzed code, specialized for each context. For dead code queries, we should only flag a line of code as dead if it is dead in all such instances.

Example

header_debug.h

void log(const char *a) {
  printf("%s", a);
}

header.h

void log(const char *a) {}

file.cpp

#if DEBUG
  #include 'header_debug.h
#else
  #include 'header.h
#endif

int main() {
  log("Hello world");
}
@lcartey lcartey added the false positive/false negative An issue related to observed false positives or false negatives. label Sep 26, 2024
@lcartey lcartey self-assigned this Sep 26, 2024
@lcartey lcartey added Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address Impact-Medium labels Sep 26, 2024
@lcartey lcartey moved this from Reported to Ready for review in Coding Standards Public Development Board Sep 26, 2024
@github-project-automation github-project-automation bot moved this from Ready for review to Done in Coding Standards Public Development Board Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium
Projects
1 participant