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

            Bug ID: 109871
           Summary: error: call of overloaded ... ambiguous (std::vector
                    vs designated initializers)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu.ojxq8 at dralias dot com
  Target Milestone: ---

When calling an overloaded function or constructor that takes a std::vector, as
well as a struct that allows designated initializers, the code is incorrectly
rejected by all versions of GCC, but accepted by Clang.

Example:

----------------
#include <vector>
struct S {};
struct Options {
    int opt{};
};
void A(std::vector<S>) {}
void A(Options) {}
int main() { A({.opt = 1}); }
----------------

Error:

----------------
<source>: In function 'int main()':
<source>:8:15: error: call of overloaded 'A(<brace-enclosed initializer list>)'
is ambiguous
    8 | int main() { A({.opt = 1}); }
      |              ~^~~~~~~~~~~~
<source>:6:6: note: candidate: 'void A(std::vector<S>)'
    6 | void A(std::vector<S>) {}
      |      ^
<source>:7:6: note: candidate: 'void A(Options)'
    7 | void A(Options) {}
      |      ^
Compiler returned: 1
----------------

There is PR 59389 and PR 86997, but they seem unrelated because they are not
about designated initializers.

Reply via email to