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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Inconsistent __is_pointer_interconvertible_base_of  results for direct vs. templated calls
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          romanova-ekaterina
      </td>
    </tr>
</table>

<pre>
    Consider the following test:

{code:java}
## Source code

#include <iostream>
class A {};
class B : public A {};

template <class _Base, class _Derived>
inline constexpr bool is_pointer_interconvertible_base_of_v = __is_pointer_interconvertible_base_of(_Base, _Derived);

int main() {
    std::cout << __is_pointer_interconvertible_base_of(const A, A) << std::endl;     
    std::cout << is_pointer_interconvertible_base_of_v<const A, A> << std::endl;

    std::cout << __is_pointer_interconvertible_base_of(const A, B) << std::endl;     
    std::cout << is_pointer_interconvertible_base_of_v<const A, B> << std::endl;     


## Observed Result
1
0
1
1 {code}

When calling __is_pointer_interconvertible_base_of(const A, A) directly, the result is 1. It is expected behavior. But, when using the templated version it returns 0. For (const A, B), both returns 1 as expected.

The direct call and the template call to should yield the same result, but they do not. 

X86_64 gcc (version 14.1) shows correct result:

Output:
{code:java}
1
1
1
1 {code}


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVU2P4zYM_TXyhRjDlpw4OfhgJxtgTwu0BdqboQ9OrK0iBZLs2fn3hWwnO9PtFEHRwwKJFTMU3-OjSPEQ9NkiNmTTkc0x42McnG-8u3DrJv6Ef_KIXlueCadem4OzQSv0EAeEZ2eMe9H2DBFDJKwlxfypO-kUEtZ-5RMn9THZKCOUwa9u9BJh_nvxpUxbaUaFQNhBuxA98gthn0jRSsNDgBZI3aUgrLvbOiCshesojJZ_cyBFG_FyNTzOERf_vuMBCT3A-npErydUC4y2RtvEyYaI364ehHMGdOivTtuIvp-f0tkJfdTCYC94wN499xMQdoS-f8CX0N2dxB2e7u-ctY1w4doSuiN0P2dUtORASVvAuoSoksSslW6MKTfCDg-Dz9lBm-DbGWDZfo-JVhnCOngHuT4fIvKQXqkgb4mwTx8RWVR5T-f_EqD7WQTo_kWAj4jUR7h3TuqoLyKgn1DBLxhGE0nRlqSYXdNawq0Zly4s2t8HtCC5Malt_-vpUdqjjOY1GdIg8DM26ABlDp_nH_jtijKiAoEDn7TzOXRjTBteEoMxzGNjQLh1q4IJfdDOgo7gMY7eBihyODkPP9YvrcLF4e5ZAv8Omi-5_jbgSnXOGLhV7yAXa3QQBjcaBa8azeIR-OWW1Yw0xmR-BeXAupivJfhjt-23FZylTAxv9MsqL5NIYXAvAaTzM4E12G1Gfhnjdby9_sO8LN9-fyhiphqm9mzPM2zKuqoYrdieZkOzU-VmJ6qSF2KzqbkQ262ot5LKPa0plSrTDS3opqjKglLGSprTsqzVjglJlSi2yEhV4IVrkxszXXLnz5kOYcSmZBtas8xwgSbMlwWl0nB7JpSme8M3acOTGM-BVIXRIYbvIaKOZr5hlh2bI3y2qaA6RLTxsWMIq4QBnp2_lXUK-ZsDlMoZstGbZojxGpK69ETo6azjMIpcuguhp0RqXZ6u3n1FGQk9zUkGQk9rnlND_woAAP__f2s54Q">