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

            Bug ID: 71468
           Summary: explicit ctor and overload resolution
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g...@axel-naumann.de
  Target Milestone: ---

GCC and clang disagree; I tend to be on clang's side here:

#include <initializer_list>
struct D {
  D(std::initializer_list<double>);
};

struct E {
  explicit E(double, bool);
};

struct F {
  F(const E&);
  F(const D&);
};

void use() {
  F f({0., 1.});
}

g++ prog.cc -Wall -Wextra -std=gnu++1z -pedantic-errors "-fsyntax-only"

prog.cc: In function 'void use()':
prog.cc:16:15: error: call of overloaded 'F(<brace-enclosed initializer list>)'
is ambiguous
   F f({0., 1.});
               ^
prog.cc:12:3: note: candidate: F::F(const D&)
   F(const D&);
   ^
prog.cc:11:3: note: candidate: F::F(const E&)
   F(const E&);
   ^

Should the path through E really be an equally good match here?

Cheers, Axel.

Reply via email to