Closed lcartey closed 4 months ago
Cannot reproduce an amended version of the test case (bar
is private).
For each instantiation we get an ExprStmt
for t
in bar
, however the location for each of those is the same and the query already excludes different ExprStmt
s with the same location.
@lcartey Is there more context that we can use to reproduce?
Re-reviewing the original bug report I believe I misdiagnosed this issue - it is actually completely unrelated to templates.
A fuller reproduction case is as follows:
class Test {
public:
friend constexpr void swap(Test &lhs, Test &rhs) noexcept { lhs.swap(rhs); }
void swap(Test &other) noexcept;
};
void test_swap() {
Test a1, a2;
swap(a1, a2);
}
The query reports that the function swap
is defined on the same line as the expression statement lhs.swap(rhs)
. Reviewing the AUTOSAR rule, I don't believe the intention is to report such cases - the rule itself does not mention functions either way, and it certainly does not make sense to report the function declaration in which an expression statement is declared as contravening in this case.
As the problem is distinctly different from this initial bug report, I'm closing this as "Doesn't reproduce" and opening a new issue here to track the function problem: https://github.com/github/codeql-coding-standards/issues/628
In debugging this issue, I identified a couple more problems with A7-1-7
and logged those separately:
Affected rules
A7-1-7
Description
In a template class or template function we may report the same logical expression in multiple template instantiations.
Example