From e65958b9aa1154a9207995d3ab6f04649e675b46 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sat, 23 Jan 2021 06:49:49 +1000 Subject: [PATCH] tools/analyse: explicit size unique_bytes accumulator This avoids unsigned overflow. --- tools/analyse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/analyse.cpp b/tools/analyse.cpp index a83a660..051434a 100644 --- a/tools/analyse.cpp +++ b/tools/analyse.cpp @@ -236,7 +236,7 @@ int main (int argc, char const **argv) auto const unique_bytes = std::accumulate ( src.begin (), src.end (), - 0, [] (auto const &accum, auto const &rhs) { return accum + rhs.size (); } + std::uintmax_t {0}, [] (auto const &accum, auto const &rhs) { return accum + rhs.size (); } ); auto const duplicated_bytes = total_bytes - unique_bytes;