From af64122ec8aa46deb1d7b1a79fe4dc28d0e661e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
Date: Thu, 24 Jul 2025 22:45:12 +0200
Subject: [PATCH 1/2] Add FLINT_NORETURN to function pointer argument

In flint_set_abort and flint_set_throw
---
 src/generic_files/exception.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/generic_files/exception.c b/src/generic_files/exception.c
index 42c02a3a20..62aead1487 100644
--- a/src/generic_files/exception.c
+++ b/src/generic_files/exception.c
@@ -44,37 +44,25 @@ void __flint_set_throw_init(void)
 FLINT_NORETURN void (* abort_func)(void) = abort;
 FLINT_NORETURN void (* throw_func)(flint_err_t, const char *, va_list) = __flint_throw;
 
-void flint_set_abort(void (* func)(void))
+void flint_set_abort(void (* func)(void) FLINT_NORETURN)
 {
 #if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
     pthread_once(&abort_func_init, __flint_set_abort_init);
     pthread_mutex_lock(&abort_func_lock);
 #endif
-
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_IGNORE_INCOMPATIBLE_FUNCTION_POINTER_TYPES
-DIAGNOSTIC_IGNORE_DISCARDED_QUALIFIERS
     abort_func = func;
-DIAGNOSTIC_POP
-
 #if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
     pthread_mutex_unlock(&abort_func_lock);
 #endif
 }
 
-void flint_set_throw(void (* func)(flint_err_t, const char *, va_list))
+void flint_set_throw(void (* func)(flint_err_t, const char *, va_list) FLINT_NORETURN)
 {
 #if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
     pthread_once(&throw_func_init, __flint_set_throw_init);
     pthread_mutex_lock(&throw_func_lock);
 #endif
-
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_IGNORE_INCOMPATIBLE_FUNCTION_POINTER_TYPES
-DIAGNOSTIC_IGNORE_DISCARDED_QUALIFIERS
     throw_func = func;
-DIAGNOSTIC_POP
-
 #if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
     pthread_mutex_unlock(&throw_func_lock);
 #endif

From 2e8cbcbafcaf85b592cff742ddde24a61dd8fa29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
Date: Fri, 25 Jul 2025 00:48:37 +0200
Subject: [PATCH 2/2] Ugly compiler workaround

---
 src/generic_files/exception.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/generic_files/exception.c b/src/generic_files/exception.c
index 62aead1487..6dd498ce52 100644
--- a/src/generic_files/exception.c
+++ b/src/generic_files/exception.c
@@ -12,7 +12,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#define flint_set_abort gurkmacka
+#define flint_set_throw cclusi
 #include "flint.h"
+#undef flint_set_abort
+#undef flint_set_throw
 
 #undef FLINT_NORETURN
 #if defined(__GNUC__)
