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

M0-1-9: Wrong dead code detection on function templates #604

Open
nbusser opened this issue Jun 1, 2024 · 1 comment
Open

M0-1-9: Wrong dead code detection on function templates #604

nbusser opened this issue Jun 1, 2024 · 1 comment
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Low user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@nbusser
Copy link

nbusser commented Jun 1, 2024

Affected rules

  • M0-1-9

Description

When using template type, some irrelevant M0-1-9 warnings are triggered

Example

template <typename T>
void false_positive() {
  T t;
  std::cin >> t; // Triggers M0-1-9
}

template <typename T>
void true_negative() {
  std::uint32_t u32;
  std::cin >> u32;
}
@nbusser nbusser added the false positive/false negative An issue related to observed false positives or false negatives. label Jun 1, 2024
@lcartey lcartey added Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address Impact-Low user-report Issue reported by an end user of CodeQL Coding Standards labels Jun 7, 2024
@lcartey
Copy link
Collaborator

lcartey commented Jun 7, 2024

Thanks for the report! This is related to reporting incomplete results in the uninstantiated copy of a template in our model. std::cin >> t is not resolved to a call target in the uninstantiated template copy, so we incorrectly assume it's pure (e.g. no side-effects) and therefore can be removed. We can adjust our concept of pure expression statements to eliminate this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Low user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

No branches or pull requests

2 participants