[v3] Fix hash_prime_size_policy_imp for 64-bit machines

Jonathan Lennox lennox@cs.columbia.edu
Thu Jun 22 14:45:00 GMT 2006


Paolo Carlini writes:
> -      num_distinct_sizes = 31
> +      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,     
...

> -  static const std::size_t g_a_sizes[num_distinct_sizes] =
> +  static const std::size_t g_a_sizes[num_distinct_sizes_64_bit] =
...

> +      /* 30    */ (unsigned long)8589934583ull,
> +      /* 31    */ (unsigned long)17179869143ull,
> +      /* 32    */ (unsigned long)34359738337ull,
...

Does this work if sizeof(unsigned long) < sizeof(std::size_t), e.g. 32-bit
long and 64-bit size_t?  I don't know if that's a supported configuration,
but it seems like this could be avoided by making just making this cast to
std::size_t in general. 

-- 
Jonathan Lennox
lennox at cs dot columbia dot edu



More information about the Gcc-patches mailing list