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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jason Liam from comment #7)
> (In reply to Andrew Pinski from comment #5)
> > std::vector 's constructor which takes std::size_t is marked as explicit.
> 
> But you're missing that the initializer list ctor is preferred/choosen over
> the size_t arg ctor. 

That is different from your original example.
This is closer to your original example:
```
#include <initializer_list>

struct B
{
  B(std::initializer_list<double>);
};

struct C
{
  explicit C(int);
};


void func(B);
void func(C);

int main() {
    func({ 4.2 });
}
```

here we have two calls to func, one which takes B and the other which takes C.
In the case case of copy-list-initialization, it is ambigous which is to be
constructed as copy-list-initialization for overload resolution; explicit
constructors are looked at but only an error if it was chosen. Note narrowing
is not taken into account for overload resolution too; maybe that is what you
are missing.

Again read https://wg21.link/cwg1228 which talks about this not being a defect
in the C++ standard; this is how the standard is written.

Anyways clang's bug report is https://github.com/llvm/llvm-project/issues/28016
.

>implying the the second overload is not even viable so how can it make the 
>call ambiguous.

I should note that is not have overload resolution works either.

Reply via email to