From b840c0be95d71e952b7865fbdffe327c4b22dcc9 Mon Sep 17 00:00:00 2001 From: Michael Bell Date: Sat, 7 Nov 2020 22:23:13 +0000 Subject: [PATCH] Fix bit-shift overflow in MLD partition step for Windows builds For very large graphs, generation of MLD level masks fail on Windows due to bit shift overflow of unsigned long values. Correct by using unsigned long long literals, which are 64 bit on all major systems. --- CHANGELOG.md | 3 +++ include/partitioner/multi_level_partition.hpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2179a18c0..c00c30248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ - Changes from 5.23.0 - Infrastructure - CHANGED: Bundled protozero updated to v1.7.0. [#5858](https://github.com/Project-OSRM/osrm-backend/pull/5858) + - Windows: + - FIXED: Fix bit-shift overflow in MLD partition step. [#5878](https://github.com/Project-OSRM/osrm-backend/pull/5878) + # 5.23.0 - Changes from 5.22.0 diff --git a/include/partitioner/multi_level_partition.hpp b/include/partitioner/multi_level_partition.hpp index 28f21fd4c..8dffe4d04 100644 --- a/include/partitioner/multi_level_partition.hpp +++ b/include/partitioner/multi_level_partition.hpp @@ -212,10 +212,10 @@ template class MultiLevelPartitionImpl final // create mask that has `bits` ones at its LSBs. // 000011 BOOST_ASSERT(offset < NUM_PARTITION_BITS); - PartitionID mask = (1UL << offset) - 1UL; + PartitionID mask = (1ULL << offset) - 1ULL; // 001111 BOOST_ASSERT(next_offset < NUM_PARTITION_BITS); - PartitionID next_mask = (1UL << next_offset) - 1UL; + PartitionID next_mask = (1ULL << next_offset) - 1ULL; // 001100 masks[lidx++] = next_mask ^ mask; });