Skip to content
Latchkey

gcc/clang "call of overloaded X is ambiguous" in CI

More than one overload is an equally good match for the call. Each requires the same conversion rank, so overload resolution has no unique best candidate.

What this error means

A call fails with "is ambiguous" and lists two or more equally viable candidates, often after an implicit conversion (int to both long and double) ties.

gcc
app.cpp:7:3: error: call of overloaded 'f(int)' is ambiguous
note: candidate: 'void f(long)'
note: candidate: 'void f(double)'

Common causes

How to fix it

Disambiguate the call

  1. Cast the argument to the exact parameter type of the intended overload.
  2. Or call with a literal whose type matches one overload uniquely.
gcc
f(static_cast<long>(x));   // selects f(long) unambiguously

How to prevent it

  • Design overload sets so argument types map to one candidate, and cast at call sites when a conversion would otherwise tie.

Frequently asked questions

What causes ""call of overloaded ... is ambiguous""?
A call fails with "is ambiguous" and lists two or more equally viable candidates, often after an implicit conversion (int to both long and double) ties.
How do I fix "call of overloaded ... is ambiguous"?
Disambiguate the call

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card