google / farmhash

Automatically exported from code.google.com/p/farmhash
MIT License
626 stars 99 forks source link

Compiler warnings when 64-bit size_t is squashed to 32-bits #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try compiling farmhash on a 64-bit Mac using Xcode 6.x

What is the expected output? What do you see instead?
I expect it to compile clean. Instead I get a ton of warnings:
farmhash.cc:995:26: Implicit conversion loses integer precision: 'size_t' (aka 
'unsigned long') to 'uint32_t' (aka 'unsigned int')

What version of the product are you using? On what operating system?
farmhash-1.1.0

Please provide any additional information below.

Not that anybody would try to hash 4+ gigabytes of data, but if they do, will 
it still work?

If you feel that losing precision is intentional, then a bunch of 
static_cast<uint32_t>(len) would do the trick.

Original issue reported on code.google.com by daryll...@gmail.com on 30 Jun 2015 at 5:56

jbosboom commented 7 years ago

If these truncations are indeed intentional and don't affect the hash quality, it would be nice to mention them in the README. There are also some -Woverflow warnings ("overflow in implicit constant conversion") in what seems to be a vector literal in farmhashte::Hash64Long that should similarly be fixed or noted as not a problem.