no matching function for call to C/C++ Origin: Application & API OSI layer 7 · Application Last updated 15 Oct 2026

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.

Exact message you may see no matching function for call tono matching constructor for initialization ofno known conversion for argumentcandidate expectscandidate function not viable
Seen on: C/C++ GCC Clang

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

  1. Compare your call with the first "candidate:" line
  2. Convert explicitly (static_cast) or change the parameter type
  3. Make reference parameters const T& when passing temporaries

Detailed fix by platform

GCC / Clang

  1. Add -fdiagnostics-show-template-tree for long template messages, or read only the first note under each candidate

C++

  1. 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

cpp
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

  1. Count — Same number of arguments as the candidate?
  2. Types — Which "no known conversion" line applies?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

AddressSanitizer: heap-buffer-overflow — C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N (C/C++)AddressSanitizer: hea…AddressSanitizer: heap-use-after-free — C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free (C/C++)AddressSanitizer: hea…C2664 — MSVC: error C2664: cannot convert argument 1 from 'X' to 'Y' (C/C++)C2664call of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…cannot declare variable to be of abstract type — C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) (C/C++)cannot declare variab…E0061: this function takes N arguments but M were supplied — Rust: error[E0061]: this function takes 2 arguments but 1 argument was supplied (Rust)E0061: this function …expected primary-expression before — C++: error: expected primary-expression before ')' token (C/C++)expected primary-expr…implicitly deleted — C++: error: call to implicitly-deleted default constructor of 'X' (C/C++)implicitly deletedno matchi…

Explore the map of this error Full error map →

🧠 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.