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

    <tr>
        <th>Summary</th>
        <td>
            Clang++ issues warning that SFINAE-disabled conversion function will never be used.
        </td>
    </tr>

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

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

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

<pre>
    Hello everyone,

I have a short sample program:

```
#include <type_traits>

template <typename T>
struct d {
    template <bool Dependent = false, class = std::enable_if_t<(Dependent || false)>>
    operator d<T>() { return *this; }
};

int main() { [[maybe_unused]] d<int> a; }
```

Compiling gives the following warning:
```
 clang++-12 ./example.cc
./example.cc:6:5: warning: conversion function converting 'd<int>' to itself will never be used [-Wclass-conversion]
    operator d<T>() { return *this; }
    ^
./example.cc:9:38: note: in instantiation of template class 'd<int>' requested here
int main() { [[maybe_unused]] d<int> a; }
                                     ^
1 warning generated.
```

I used **Clang++ 12** from Ubuntu for the above case.
Here's also a link with the source in Compiler Explorer and the compiler set to **Clang++ 15**: https://godbolt.org/z/9WaGenEP5

My expectation would be - given that the conversion operator is disabled by SFINAE - that no warning should be issued.
It seems to me that the warning is generated from all member functions, but no actual instantiation/overload set is formed?

Am I wrong to assume there should not be a diagnostic issued?

This is of course a MWE. In my code struct d is a more complicated class template with more template parameters.
I realize it's not your job to teach me C++, but assuming that Clang shows the correct behaviour here, is there a standard conformant way of offering conversion operators for certain class template instantiations that would also compile warning-free under "-Wclass-conversion" with Clang?

Thanks and best regards,
Hannes
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk1v4zYT_jX0ZWBDJuM4Pvjgz3dz2BcFusUeg5E0krhLkS6Hstf76wtStuy4aVGgTQI7YTjD52toIbOuLdFSzNZith1hFxrnlw1aS3wizTkWzSh35Xn5iYxxQEfyZ2dJyI3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