From 799ea8317d5697b20df854169acb345f8b33d148 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Wed, 29 Jan 2025 19:43:17 +0100
Subject: [PATCH] spread_footprints.cpp, SpreadFootprints(): fix incorrect
 conversion int to uint64

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19780
---
 pcbnew/autorouter/spread_footprints.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pcbnew/autorouter/spread_footprints.cpp b/pcbnew/autorouter/spread_footprints.cpp
index 555fe7f1e0..d0fc484c29 100644
--- a/pcbnew/autorouter/spread_footprints.cpp
+++ b/pcbnew/autorouter/spread_footprints.cpp
@@ -121,7 +121,7 @@ std::optional<rectpack2D::rect_wh> spreadRectangles( rect_vector& vecSubRects, i
     return result;
 }
 
-
+#include <wx/log.h>
 void SpreadFootprints( std::vector<FOOTPRINT*>* aFootprints, VECTOR2I aTargetBoxPosition,
                        bool aGroupBySheet, int aComponentGap, int aGroupGap )
 {
@@ -305,10 +305,10 @@ void SpreadFootprints( std::vector<FOOTPRINT*>* aFootprints, VECTOR2I aTargetBox
 
         // Avoid too large coordinates: Overlapping components
         // are better than out of screen components
-        if( (uint64_t) target_pos.x + (uint64_t) target_size.x > INT_MAX / 2 )
+        if( (int64_t) target_pos.x + (int64_t) target_size.x > INT_MAX / 2 )
             target_pos.x -= INT_MAX / 2;
 
-        if( (uint64_t) target_pos.y + (uint64_t) target_size.y > INT_MAX / 2 )
+        if( (int64_t) target_pos.y + (int64_t) target_size.y > INT_MAX / 2 )
             target_pos.y -= INT_MAX / 2;
 
         for( auto& [fpSize, fpPair] : sizeToFpMap )