From 13177172d0aa6bacbfd8a3b0e47f0b7409a09671 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 4 Feb 2018 08:02:35 +0000 Subject: [PATCH] Fix initialization of array with GCC. Previously, when handling zero-sized array of const objects we used a const version of aligned_storage_t, which is not an array type. However, GCC complains about initialization of the form: array arr = {}; This patch fixes that bug by making the dummy object used to represent the zero-sized array an array itself. This avoids GCC's complaints about the uninitialized const member. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324194 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/array | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/array b/include/array index 4a89ea90d..068ab506a 100644 --- a/include/array +++ b/include/array @@ -146,21 +146,19 @@ struct __array_traits { template struct __array_traits<_Tp, 0> { typedef typename aligned_storage::value>::type - _NonConstStorageT; + _NonConstStorageT[1]; typedef typename conditional::value, const _NonConstStorageT, _NonConstStorageT>::type _StorageT; - typedef typename remove_const<_Tp>::type _NonConstTp; + _LIBCPP_INLINE_VISIBILITY - static _NonConstTp* __data(_NonConstStorageT& __store) { - _StorageT *__ptr = std::addressof(__store); - return reinterpret_cast<_NonConstTp*>(__ptr); + static _NonConstTp* __data(_NonConstStorageT &__store) { + return reinterpret_cast<_NonConstTp*>(__store); } _LIBCPP_INLINE_VISIBILITY - static const _Tp* __data(const _StorageT& __store) { - const _StorageT *__ptr = std::addressof(__store); - return reinterpret_cast(__ptr); + static const _Tp* __data(const _StorageT &__store) { + return reinterpret_cast(__store); } _LIBCPP_INLINE_VISIBILITY