C++: error: no matching function for call to 'f(int, const char*)'
No overload of the function accepts the arguments you passed — wrong count, wrong types, or a missing conversion.
no matching function for call tono matching constructor for initialization ofno known conversion for argumentcandidate expectscandidate function not viable Meaning
GCC lists every candidate and why it was rejected ("candidate expects 2 arguments, 1 provided", "no known conversion from ..."). Read the first candidate that looks like what you meant. For constructors the message says no matching function for call to 'X::X(...)'.
Common causes
- Wrong number of arguments
- Argument type has no implicit conversion to the parameter type
- Passing a temporary to a non-const reference parameter
- Template deduction failed because arguments disagree (for example int and double)
- Function declared in a different namespace or not yet declared
⚡ Quick fix
- Compare your call with the first "candidate:" line
- Convert explicitly (
static_cast) or change the parameter type - Make reference parameters
const T&when passing temporaries
Detailed fix by platform
GCC / Clang
- Add
-fdiagnostics-show-template-treefor long template messages, or read only the first note under each candidate
C++
- Match the signature exactly or add an overload; for constructors check member-initialisation order and braces
Code examples
Temporary cannot bind to a non-const reference
void scale(double& factor); // takes a non-const reference
int main() {
// scale(2.0); // error: no matching function (cannot bind rvalue)
double f = 2.0;
scale(f); // OK
}
// or declare: void scale(const double& factor);How to diagnose
- Count — Same number of arguments as the candidate?
- Types — Which "no known conversion" line applies?
- Reference — Is a temporary passed to T&?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AddressSanitizer: heap-buffer-overflow C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N
- AddressSanitizer: heap-use-after-free C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free
- call of overloaded is ambiguous C++: error: call of overloaded 'f(int)' is ambiguous
Most viewed in C/C++
- terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- undefined reference to C/C++: undefined reference to `function' — collect2: error: ld returned 1 exit status
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026