From 4411de699a6f294475eb5ea915f57d3c43de40e3 Mon Sep 17 00:00:00 2001
From: Thomas Voss <mail@thomasvoss.com>
Date: Thu, 5 Sep 2024 00:04:01 +0200
Subject: Fix some integer-type bugs

---
 src/main.c   | 6 +++---
 src/parser.y | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/main.c b/src/main.c
index 56f8ef7..3854640 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,11 +52,11 @@ static bool eqnsolve(eqn_t *, uint64_t, uint64_t);
 static int  eqnprint(eqn_t *);
 static void eqnfree(eqn_t *);
 
-static uint64_t
+static int
 popcnt(uint64_t n)
 {
-#if __has_builtin(__builtin_popcount)
-	return __builtin_popcount(n);
+#if !__has_builtin(__builtin_popcountg)
+	return __builtin_popcountg(n);
 #else
     uint64_t c;
     for (c = 0; n > 0; n &= n - 1)
diff --git a/src/parser.y b/src/parser.y
index e424068..07afbe7 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -1,6 +1,7 @@
 %{
 #include <ctype.h>
 #include <err.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -80,7 +81,7 @@ expr:
 		$$.eqn = xmalloc(sizeof(eqn_t));
 		$$.eqn->type = IDENT;
 		$$.eqn->ch = $1;
-		$$.vars = 1 << (islower($1) ? $1-'a'+26 : $1-'A');
+		$$.vars = UINT64_C(1) << (islower($1) ? $1-'a'+26 : $1-'A');
 	}
 	| NOT expr        { $$ = mkunop(NOT,  $2);       }
 	| OPAR expr CPAR  { $$ = mkunop(OPAR, $2);       }
-- 
cgit v1.2.3