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

A2-10-5: id name reuse false positive with template specialization #806

Open
fjatWbyT opened this issue Dec 2, 2024 · 2 comments
Open
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day 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

@fjatWbyT
Copy link
Contributor

fjatWbyT commented Dec 2, 2024

Affected rules

  • A2-10-5

Description

Variable template defined with an specialization is alerted as identifier reuse.

Example

template<typename T, typename S>
extern constexpr bool x = false;

template<typename T>
extern constexpr bool x<T, int> = true;

Query IdentifierNameOfANonMemberObjectWithExternalOrInternalLinkageIsReused.ql warns about x in lines 2 and 5.

@fjatWbyT fjatWbyT added the false positive/false negative An issue related to observed false positives or false negatives. label Dec 2, 2024
@fjatWbyT
Copy link
Contributor Author

fjatWbyT commented Dec 2, 2024

Fix proposal: I think that template specializations could be added as an exception, although I am unsure how to capture that. I also wondered whether it should be using the template instantiated or instantiation CodeQL classes.

@lcartey
Copy link
Collaborator

lcartey commented Dec 10, 2024

Thanks! I agree, we should ignore specializations.

The standard library currently does not provide a variable template specialization class, but this can be implemented in CodeQL by looking for uninstantiated templates where one or more template arguments have been provided.

@lcartey lcartey added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address Impact-Low user-report Issue reported by an end user of CodeQL Coding Standards labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day 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