llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

No ambiguity detected in the selection of overloaded constructors from std::initializer_list #53841

Open Fedr opened 2 years ago

Fedr commented 2 years ago

The following program:

#include <initializer_list>

struct A {
    int i;
};

struct B {
    constexpr explicit B(int) {}
};

struct C {
    int v;
    constexpr C(std::initializer_list<A>) : v(1) {}
    constexpr C(std::initializer_list<B>) : v(2) {}
};

static_assert( C{{1}}.v == 1 );

according to this discussion https://stackoverflow.com/a/71096721/7325599 must be rejected due to ambiguity, but Clang accepts it now. Demo: https://gcc.godbolt.org/z/joz91q4ed

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-frontend