From: John Baldwin Date: Mon, 21 Nov 2022 22:34:07 +0000 (-0800) Subject: [libc++] : Avoid instantiating a pointer type. X-Git-Tag: upstream/17.0.6~26936 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26068c6e60324ed866a1ca2afb5cb5eb0aaf015b;p=platform%2Fupstream%2Fllvm.git [libc++] : Avoid instantiating a pointer type. 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. Reviewed By: #libc, philnik, ldionne Differential Revision: https://reviews.llvm.org/D135469 --- diff --git a/libcxx/include/__type_traits/decay.h b/libcxx/include/__type_traits/decay.h index c38bbde..f45d33b 100644 --- a/libcxx/include/__type_traits/decay.h +++ b/libcxx/include/__type_traits/decay.h @@ -42,7 +42,7 @@ public: typedef _LIBCPP_NODEBUG typename conditional < is_array<_Up>::value, - __remove_extent_t<_Up>*, + __add_pointer_t<__remove_extent_t<_Up> >, typename conditional < is_function<_Up>::value, diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp index af99154..d07a136 100644 --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -29,10 +29,14 @@ int main(int, char**) test_decay(); test_decay(); test_decay(); + test_decay(); + test_decay(); test_decay(); test_decay(); test_decay(); #if TEST_STD_VER > 11 + test_decay(); + test_decay(); test_decay(); test_decay(); test_decay();