shithub: femtolisp

Download patch

ref: 6d3bbb1c8a8b1b4a465242c5af79e1d8fdaa188e
parent: 93f71e4a1522ecaa376f68958ff4024c9c2f3902
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Oct 30 23:47:21 EDT 2024

addof_uint64: fix overflow checks for 0

--- a/cvalues.c
+++ b/cvalues.c
@@ -999,7 +999,7 @@
 fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn)
 {
 	uint64_t Uaccum = 0;
-	uint64_t Uresult;
+	uint64_t Uresult = 0;
 	int64_t Saccum = carryIn;
 	int64_t Sresult;
 	double Faccum = 0;
--- a/overflows.h
+++ b/overflows.h
@@ -12,9 +12,9 @@
 )
 
 #define addof_uint64(c,a,b) ( \
-  (b < 1)? \
-  ((-(b) <= (a))?((c=(a)+(b))?0:1):1): \
-  ((UINT64_MAX-(b) >= (a))?((c=(a)+(b))?0:1):1) \
+  b? \
+  ((UINT64_MAX-(b) >= (a))?((c=(a)+(b)),0):1): \
+  0 \
 )
 
 #define subof_uint64(c,a,b) ( \