https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107509

            Bug ID: 107509
           Summary: wrong ambiguous overloaded function error if argument
                    class is undefined
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

In the next program, struct B is only declared so foo(const B &) cannot be
called via foo({}):

struct A {};
struct B;

void foo(const A &) {}
void foo(const B &) {}

int main() {
    foo({});
}

Clang and MSVC correctly call foo(const A &) here, but GCC prints the error:
call of overloaded 'foo(<brace-enclosed initializer list>)' is ambiguous

Online demo: https://godbolt.org/z/6fxYoxjc1

Reply via email to