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

--- Comment #6 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Jonathan Wakely from comment #4)
> Before the conversion sequence that binds a reference you need to initialize
> the underlying temporary, which is a list-initialization sequence. You have
> list-initialization sequence L1 from {1,2,3} to S1 and list-initialization
> sequence L2 from {1,2,3} to S2. Neither L1 nor L2 is better than the other
> according to http://eel.is/c++draft/over.match.best#over.ics.rank-3.1

True, which is why I think it falls back to the subsequent binding to the
temporary. If you take an ambiguous list-init sequence as sufficient reason to
not look at the rest, then would not even

  struct S {};
  void f(const S &);
  void f(S &&);
  void g() { f({}); }

be ambiguous? Both start with the same list-init sequence, so neither is better
than the other. But here, GCC does look beyond that and prefer f(S &&).

I'll be happy to agree that the standard isn't clear, and that I might well be
wrong.

Reply via email to