[libcxx-commits] [PATCH] D135469: [libc++] <type_traits>: Avoid instantiating a pointer type.

John Baldwin via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 7 11:02:50 PDT 2022


bsdjhb created this revision.
Herald added a project: All.
bsdjhb requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135469

Files:
  libcxx/include/__type_traits/decay.h


Index: libcxx/include/__type_traits/decay.h
===================================================================
--- libcxx/include/__type_traits/decay.h
+++ libcxx/include/__type_traits/decay.h
@@ -42,7 +42,7 @@
     typedef _LIBCPP_NODEBUG typename conditional
                      <
                          is_array<_Up>::value,
-                         __remove_extent_t<_Up>*,
+                         typename add_pointer<__remove_extent_t<_Up>>::type,
                          typename conditional
                          <
                               is_function<_Up>::value,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135469.466123.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221007/c61c45ee/attachment.bin>


More information about the libcxx-commits mailing list