[clang] Inconsistent __is_pointer_interconvertible_base_of results for direct vs. templated calls (original) (raw)
Consider the following test:
## 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
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) and X64 msvc v19.40 VS17.10 (with /std:c++20 option) show correct result:
Output: