call of overloaded is ambiguous C/C++ Origin: Application & API Last updated 15 Oct 2026

C++: error: call of overloaded 'f(int)' is ambiguous

Two or more overloads fit equally well, so the compiler refuses to guess which function you meant.

Exact message you may see call of overloaded is ambiguouserror: call of overloaded 'f(int)' is ambiguousambiguous call to overloaded functionreference to 'count' is ambiguousreference to 'distance' is ambiguous
Seen on: C/C++ GCC Clang

Meaning

Overload resolution ranks implicit conversions. With f(long) and f(double), calling f(5) converts int to either and ties. Ambiguity also appears with nullptr vs 0, string literals vs bool, and ADL finding the same name in two namespaces.

Common causes

  • Overloads that differ only by numeric types and an argument needing conversion to both
  • Passing 0 or NULL where both pointer and integer overloads exist
  • using namespace bringing two same-named functions into scope
  • Constructors taking different arithmetic types
  • Default arguments making two overloads equally viable

⚡ Quick fix

  1. Cast or use a literal suffix (5L, 5.0f) so one overload matches exactly
  2. Use nullptr instead of 0/NULL
  3. Qualify the call (ns::f(x)) or remove the conflicting using

Detailed fix by platform

C++

  1. Add an exact overload for the argument type you pass, or call f(static_cast<long>(x))
  2. Prefer one template or std::string_view instead of many near-identical overloads

Code examples

int matches long and double equally

cpp
void f(long v);
void f(double v);

int main() {
    // f(5);               // error: call of overloaded 'f(int)' is ambiguous
    f(5L);                 // exact match for long
    f(5.0);                // exact match for double
}

How to diagnose

  1. Candidates — Which overloads are listed under the error?
  2. Argument — Exact type of the argument?
  3. Namespaces — Any using-directive adding more overloads?

🔧 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):

Assertion failed — C/C++: Assertion `x > 0' failed. Aborted (core dumped) — assert() condition was false (C/C++)Assertion failedC2065 — MSVC: error C2065: 'x': undeclared identifier (C/C++)C2065comparison of integers of different signs — C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare] (C/C++)comparison of integer…discards qualifiers — C++: error: passing 'const X' as 'this' argument discards qualifiers [-fpermissive] (C/C++)discards qualifiersdoes not name a type — C++: error: 'string' does not name a type (C/C++)does not name a typeE0308 — Rust: error[E0308]: mismatched types — expected `X`, found `Y` (Rust)E0308Floating point exception — C/C++: Floating point exception (core dumped) — SIGFPE, usually integer division by zero (C/C++)Floating point except…format expects argument of type — C: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=] (C/C++)format expects argume…call of o…

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.