[libcxx-commits] [libcxx] [libc++] Use remove_pointer builtin only for clang in traits impl (PR #91838)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 14 23:04:21 PDT 2024
Chilledheart wrote:
As described in https://github.com/llvm/llvm-project/issues/91831, from GCC's aspect the warning tells us its design decision:
```
error: use of built-in trait \u2018__remove_pointer(typename std::__Cr::decay<_Tp>::type)\u2019 in function signature; use library traits instead
```
That is that "all traits are not to be used directly" but the "library traits". Below is the gcc's library traits (libstdc++).
```
template<typename _Tp>
struct remove_pointer
{ using type = __remove_pointer(_Tp); };
```
and
```
/// Alias template for remove_pointer
template<typename _Tp>
using remove_pointer_t = typename remove_pointer<_Tp>::type;
```
To fix this issue (along with other new builts for library traits in new gcc releases), the right way is use "change the type alias to use the alias from the struct always" as I talked with a gcc maintainer.
For example, gcc's add_pointer_t traits has the same structure with remove_pointer_t. If we face the same issue in the future. We can handle it with the same way.
```
/// Alias template for add_pointer
template<typename _Tp>
using add_pointer_t = typename add_pointer<_Tp>::type;
```
https://github.com/llvm/llvm-project/pull/91838
More information about the libcxx-commits
mailing list