<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75323>75323</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `std::variant` converting constructor compiles while the C++ Standard says it must not
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          toughengineer
      </td>
    </tr>
</table>

<pre>
    According to [\[variant.ctor\]](https://eel.is/c++draft/variant.ctor) (also see [cppreference](https://en.cppreference.com/w/cpp/utility/variant/variant)) converting constructor
```c++
template<class T>
constexpr variant(T&& t) noexcept(/*...*/);
```
determines the alternative to construct as if by selecting an overload for `F(std​::​forward<T>(​t))` from an overload set `F(T_j)` where `T_j` are types of the alternatives,
e.g. for `std::variant<std::monostate, bool, int64_t, double>` the overload set would be
```c++
void F(std::monostate) {}
void F(bool) {}
void F(int64_t) {}
void F(double) {}
```

In violation of the standard this code compiles with Clang and libc++ (https://godbolt.org/z/aah9Pq9fq):
```c++
std::variant<std::monostate, bool, int64_t, double> v = 42;
```
while overload resolution of `F()` fails:
```c++
F(42); // error: ambiguous
```
<details><summary>compiler error (click/tap to expand)</summary>

```
<source>:14:3: error: call to 'F' is ambiguous
   14 |   F(42);
      |   ^
<source>:6:6: note: candidate function
    6 | void F(bool) {}
      |      ^
<source>:7:6: note: candidate function
    7 | void F(int64_t) {}
      |      ^
<source>:8:6: note: candidate function
    8 | void F(double) {}
      |      ^
```
</details>

Among libc++, libstdc++ and MSVC standard libraries only MSVC standard library gets it according to the standard so you can look at it for reference.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVsuO27gS_Rp6U4ggk7YeCy9sdQu4iwsMkGC2AUWWbSYUqZCUHc_XDyjJz9g9E2AAd0tiUXXqnHqI3Hu1M4grstyQ5duM92Fv3SrYfrdHs1MG0c0aK0-rtRDWS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