From 9502bc27a3b32fa5759ea82a76c22551620ebcd2 Mon Sep 17 00:00:00 2001 From: Nexus Web Development Date: Sat, 11 Jan 2020 15:24:10 -0500 Subject: [PATCH] Update Date.h (#529) * Remove arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Casting the value to the wider type before calling operator '-' to avoid overflow. --- include/date/date.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/date/date.h b/include/date/date.h index 027a5a4..81ca2d0 100644 --- a/include/date/date.h +++ b/include/date/date.h @@ -1564,7 +1564,7 @@ inline month operator+(const month& x, const months& y) NOEXCEPT { - auto const mu = static_cast(static_cast(x)) + (y.count() - 1); + auto const mu = static_cast(static_cast(x)) + y.count() - 1; auto const yr = (mu >= 0 ? mu : mu-11) / 12; return month{static_cast(mu - yr * 12 + 1)}; }