GCC expands the pointer type in this conditional expression even for
template types _Up that are not arrays. This raises an error when
std::decay<> is used with reference types (as is done in LLVM's
sources). Using add_pointer<> causes GCC to only instantiate a
pointer type for array types.
Details
- Reviewers
philnik ldionne - Group Reviewers
Restricted Project - Commits
- rG26068c6e6032: [libc++] <type_traits>: Avoid instantiating a pointer type.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I ran into this error in a perhaps unusual environment which is using GCC 12.0 to compile LLVM 14 (included in FreeBSD) using libc++ as the C++ runtime (rather than using libstdc++). The exact error from GCC is included in the review I opened for FreeBSD at https://reviews.freebsd.org/D36898. I forward ported the patch from LLVM 14 but do not have an easy way to test the setup I used to reproduce the GCC error on LLVM 14. I did not use __add_pointer_t because line 49 uses add_pointer<>, but if __add_pointer_t is preferred I'm happy to switch it to that instead.
Please add a regression test in libcxx/test/std/meta/type.traits/meta.trans/meta.trans.other.
libcxx/include/__type_traits/decay.h | ||
---|---|---|
45 |
Thanks for fixing! This LGTM but I'll let @philnik give the libc++ approval since he had requested changes.
clang-format not found in user’s local PATH; not linting file.