mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-21 04:50:24 +08:00
libstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]
On a 16-bit target such as msp430 we get errors about narrowing long values to size_t, which is only 16-bit. When --enable-libstdcxx-pch is used the <bits/extc++.h> header breaks the build because of these narrowing errors. libstdc++-v3/ChangeLog: PR libstdc++/105681 * include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp: Limit ga_sizes array to values that fit in size_t. * include/ext/random [__SIZE_WIDTH < 32] (sfmt86243) (sfmt86243_64, sfmt132049, sfmt132049_64, sfmt216091) (sfmt216091_64): Do not declare.
This commit is contained in:
parent
11e1ee1b38
commit
367740bf6d
@ -46,15 +46,23 @@ namespace detail
|
||||
{
|
||||
enum
|
||||
{
|
||||
num_distinct_sizes_16_bit = 14,
|
||||
num_distinct_sizes_32_bit = 30,
|
||||
num_distinct_sizes_64_bit = 62,
|
||||
num_distinct_sizes = sizeof(std::size_t) != 8 ?
|
||||
num_distinct_sizes_32_bit : num_distinct_sizes_64_bit,
|
||||
// The number of values is limited by the width of size_t.
|
||||
// Maybe we could just use (__SIZE_WIDTH__ - 2) here.
|
||||
#if __SIZE_WIDTH__ >= 64
|
||||
num_distinct_sizes = num_distinct_sizes_64_bit
|
||||
#elif __SIZE_WIDTH__ >= 32
|
||||
num_distinct_sizes = num_distinct_sizes_32_bit
|
||||
#else
|
||||
num_distinct_sizes = num_distinct_sizes_16_bit
|
||||
#endif
|
||||
};
|
||||
|
||||
// Originally taken from the SGI implementation; acknowledged in the docs.
|
||||
// Further modified (for 64 bits) from tr1's hashtable.
|
||||
static const std::size_t g_a_sizes[num_distinct_sizes_64_bit] =
|
||||
static const std::size_t g_a_sizes[num_distinct_sizes] =
|
||||
{
|
||||
/* 0 */ 5ul,
|
||||
/* 1 */ 11ul,
|
||||
@ -70,6 +78,7 @@ namespace detail
|
||||
/* 11 */ 14033ul,
|
||||
/* 12 */ 28411ul,
|
||||
/* 13 */ 57557ul,
|
||||
#if __SIZE_WIDTH__ >= 32
|
||||
/* 14 */ 116731ul,
|
||||
/* 15 */ 236897ul,
|
||||
/* 16 */ 480881ul,
|
||||
@ -86,6 +95,7 @@ namespace detail
|
||||
/* 27 */ 1164186217ul,
|
||||
/* 28 */ 2364114217ul,
|
||||
/* 29 */ 4294967291ul,
|
||||
#if __SIZE_WIDTH__ >= 64
|
||||
/* 30 */ (std::size_t)8589934583ull,
|
||||
/* 31 */ (std::size_t)17179869143ull,
|
||||
/* 32 */ (std::size_t)34359738337ull,
|
||||
@ -118,6 +128,8 @@ namespace detail
|
||||
/* 59 */ (std::size_t)4611686018427387847ull,
|
||||
/* 60 */ (std::size_t)9223372036854775783ull,
|
||||
/* 61 */ (std::size_t)18446744073709551557ull,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@ -346,6 +346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
0xa3ac4000U, 0xecc1327aU>
|
||||
sfmt44497_64;
|
||||
|
||||
#if __SIZE_WIDTH__ >= 32
|
||||
|
||||
typedef simd_fast_mersenne_twister_engine<uint32_t, 86243, 366,
|
||||
6, 7, 19, 1,
|
||||
@ -396,6 +397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
0xf8000001U, 0x89e80709U,
|
||||
0x3bd2b64bU, 0x0c64b1e4U>
|
||||
sfmt216091_64;
|
||||
#endif // __SIZE_WIDTH__ >= 32
|
||||
|
||||
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user