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
- Cast the argument to the exact parameter type of the intended overload.
- Or call with a literal whose type matches one overload uniquely.
gcc
f(static_cast<long>(x)); // selects f(long) unambiguouslyHow 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
gcc/clang "static_assert needs a constant expression" in CIFix gcc/clang "non-constant condition for static assertion" in CI - static_assert was given a condition that…
gcc/clang "template argument deduction/substitution failed" in CIFix gcc/clang "template argument deduction/substitution failed" in CI - a template candidate was rejected bec…
gcc/clang "array bound is not an integer constant" in CIFix gcc/clang "array bound is not an integer constant before ']'" in CI - a fixed-size array is sized by a ru…