You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e100161
Browse filesBrowse the repository at this point in the historyBrowse files
Fix #15104 FP functionStatic and constParameterReference: call of overloaded member function template resolved to free function with the same name (#8936)
https://trac.cppcheck.net/ticket/15104
```cpp
struct DS;
void select(int a, int b);
class Query {
int m = 0;
public:
template <typename Callback>
int select(DS &ds, Callback cb) { cb(m); return 0; }
template <typename Callback>
int select(DS *ds, Callback cb) { return select(*ds, cb); }
int select(DS &ds) { return select(ds, [](int) {}); } // FP functionStatic, constParameterReference
};
```
`Scope::findFunction()` couldn't choose between `select(DS &, Callback)`
and `select(DS *, Callback)` for `select(ds, ...)` with `DS &ds`: the
pointer overload stayed a candidate although an object can't be passed
for a pointer to its class. As the call was ambiguous in the class
scope, the lookup continued in the enclosing scopes and picked the free
`select(int, int)`.
A candidate is now removed when a plain variable argument and the
parameter have the same class type but only one of them is a pointer:
- an object for a `C*` parameter, unless the class (or one of its base
classes, or an unknown base class) has a conversion operator
- a `C*` for a non-const lvalue reference `C&` (a temporary from a
converting constructor can bind to `const C&` and `C&&`, so these are
kept)
By-value parameters, arrays and function pointers/references are not
affected. Incomplete types are assumed to have no conversion operator.
Built-in and library types, and arguments that are not plain variables
(`*p`), are not covered.
When a member overload can't be resolved, the lookup still continues in
the enclosing scopes although the member functions hide the free
function (C++ name hiding). That is a separate issue and not changed
here.
This PR was created by Claude Code (an AI coding agent) on behalf of
@autoantwort.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments