From 0a202dcff3b90429021ee7b7376df5d11865aa41 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 3 Oct 2023 14:36:32 +0200 Subject: [PATCH] Fixed Vojtech's out of boundary assert in Clipper library. --- src/clipper/clipper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 6cbf45b79c..0229f9ad18 100644 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -97,7 +97,8 @@ inline IType Round(double val) { double v = FRound(val); #if defined(CLIPPERLIB_INT32) && ! defined(NDEBUG) - static constexpr const double hi = 65536 * 16383; + static_assert(sizeof(IType) == 4 || sizeof(IType) == 8, "IType must be int32 or int64"); + static constexpr const double hi = 65536. * 16383. * (sizeof(IType) == 4 ? 1 : 65536. * 65536.); if (v > hi || -v > hi) throw clipperException("Coordinate outside allowed range"); #endif