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

    <tr>
        <th>Summary</th>
        <td>
            [clang] User-defined conversion function called instead of converting constructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    Just noticed the following example fail to compile starting with GCC 14. MSVC also agrees that the converting constructor should be called, and also produces a compile error, but Clang accepts it and calls `UISize::operator IntSize`:

```c++
template <typename T> struct Size {
  template <typename U> Size(Size<U> other) : m_width(other.width()) {}
  T width();
  T m_width;
};
using IntSize = Size<int>;
struct UIDimension {};
struct UISize : Size<UIDimension> {
  operator IntSize();
};


void test(UISize u) { IntSize foo = IntSize(u); }
```

Godbolt: https://godbolt.org/z/MMYWc68xP

Compile error with GCC trunk (14.0.1 20240420):
```
<source>: In instantiation of 'Size<T>::Size(Size<U>) [with U = UIDimension; T = int]':
<source>:13:46: required from here
   13 | void test(UISize u) { IntSize foo = IntSize(u); }
      | ^
<source>:2:66: error: cannot convert 'UIDimension' to 'int' in initialization
    2 |   template <typename U> Size(Size<U> other) : m_width(other.width()) {}
      | ~~~~~~~~~~~^~
      | |
      | UIDimension
```

I'm not sure who's right here, but this discrepancy in behavior is definitely odd.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vctu6zYTfhp6M4ghkbrYCy9sOT7IDwT4gZO06KqgpZHFliJdcpScZHGevSAlxc6lu6KGoETDmW9mvrlQeq9OBnHD8h3L9ws5UGfdZoeOpJZmvzja5mXzv8ETGEuqxgaoQ2it1vZZmRPgD9mfNUIrlQayUNv-rDSCJ-koKDwr6uBbVUGaLeH--y8VSO0tyJND9ECdpIhYW_OEo0VtjSc31GQd-M4OuoEjQi21xobxCqRpRoyzs81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