`A2-10-5`: id name reuse false positive with template specialization
fjatWbyT opened this issue · 2 comments
fjatWbyT commented
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 commented
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 commented
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.