public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109871] New: error: call of overloaded ... ambiguous (std::vector vs designated initializers)
@ 2023-05-16  7:44 gnu.ojxq8 at dralias dot com
  2023-05-16 13:54 ` [Bug c++/109871] error: call of overloaded ... is " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gnu.ojxq8 at dralias dot com @ 2023-05-16  7:44 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-19 15:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16  7:44 [Bug c++/109871] New: error: call of overloaded ... ambiguous (std::vector vs designated initializers) gnu.ojxq8 at dralias dot com
2023-05-16 13:54 ` [Bug c++/109871] error: call of overloaded ... is " ppalka at gcc dot gnu.org
2023-05-16 14:06 ` ppalka at gcc dot gnu.org
2023-05-16 16:39 ` cvs-commit at gcc dot gnu.org
2023-05-16 16:41 ` ppalka at gcc dot gnu.org
2023-05-19 15:10 ` cvs-commit at gcc dot gnu.org
2023-05-19 15:10 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).