valhalla icon indicating copy to clipboard operation
valhalla copied to clipboard

Cast from UInt64 to Int could be problematic on macOS

Open cduvenhorst opened this issue 1 year ago • 3 comments

https://github.com/valhalla/valhalla/blob/5b3cd9704ffd699b992b08bc4a5bf60e34d318f5/src/tyr/serializers.cc#L442

num_lanes_blocked is defined as UInt64, writer writes Int. This gives an compiler error on default build configuration.

cduvenhorst avatar Oct 26 '23 09:10 cduvenhorst

it likely depends on your platform and compiler, as you can see our builds complete without issue. in practice, its highly unlikely that this matters. no roads that i know about have more than 2^31 lanes, so the number wouldnt wrap around on the signed integer conversion. that said, you are right that we should fix it. it looks like there are a number of places where we just use Int without looking at the sign :frowning_face: do you have time to submit a pr?

kevinkreiser avatar Oct 26 '23 13:10 kevinkreiser

@kevinkreiser If it's open, can I pick this issue ?

namanvats avatar Oct 31 '23 23:10 namanvats

feel free:)

nilsnolde avatar Oct 31 '23 23:10 nilsnolde