From 426ab1f172fbddba96f993761199fcfe8bfd3a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Sun, 4 Dec 2016 14:48:26 +0100 Subject: [PATCH] gc-stats: handle unsinged int overflow correctly --- src/c/alloc_2.d | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/c/alloc_2.d b/src/c/alloc_2.d index ebb259eb2..d4f438253 100644 --- a/src/c/alloc_2.d +++ b/src/c/alloc_2.d @@ -1289,11 +1289,15 @@ gather_statistics() mpz_add_ui(cl_core.bytes_consed->big.big_num, cl_core.bytes_consed->big.big_num, wrapped); - bytes = new_bytes; + mpz_add_ui(cl_core.bytes_consed->big.big_num, + cl_core.bytes_consed->big.big_num, + new_bytes); + } else { + mpz_add_ui(cl_core.bytes_consed->big.big_num, + cl_core.bytes_consed->big.big_num, + new_bytes - bytes); } - mpz_add_ui(cl_core.bytes_consed->big.big_num, - cl_core.bytes_consed->big.big_num, - new_bytes - bytes); + bytes = new_bytes; #endif mpz_add_ui(cl_core.gc_counter->big.big_num, cl_core.gc_counter->big.big_num,