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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Poor diagnostic with wrong template argument type
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang,
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    Clang diagnostic for invalid bool-to-enum template parameter conversion lacks failure detail when compared to GCC, as the following C++ snippet:

```cpp
enum endianness { little = 0, big };

template <endianness e>
inline void foo() {}

void bar() {
 foo<false>();
}
```
Fails as follows on latest clang:
```
<source>:7:5: error: no matching function for call to 'foo'
    7 |     foo<false>();
 |     ^~~~~~~~~~
<source>:4:13: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'big_endian'
    4 | inline void foo() {}
```

GCC explicitly indicates the conversion failure instead:
```
<source>:4:13: note: template argument deduction/substitution failed:
<source>:7:15: error: could not convert 'false' from 'bool' to 'endianness'
    7 |     foo<false>();
      |     ~~~~~~~~~~^~
      | |
      |               bool
```

Godbolt: https://godbolt.org/z/hnazTn3M7 (cc/ @shafik).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVM2OpDYQfprqS2lGtN0M0wcODLPsKVIOuUfGLsBZYyPbzGT2MM8e2fTfpldZBSEBKrvq-8MiBD1aohrKFyhfd2KNk_O1sNFZ7Qavx4lidLveqY-6NcKOqLQYrQtRSxycR23fhNEKe-fMQ3QPZNcZI82LEZFwEV7MFMmjdPaNfNDOohHyW8BBaLN6QkVRaIPvE1mUbl6EJ4XR4de2BdaiCBgnwsEZ4961HbEF9gLsBYPVy0IReANFvp-K7ZbLAkWTcZBVWlhLISBUL2h0jIYQ-CsWqXevR4TqFfjL1uICG3h7s5WAf4Gi0dZoS_jmtMLBOWDPwI6pb2q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