在 2025-12-26 07:33, Pali Rohár 写道:
diff --git a/mingw-w64-crt/testcases/t_sigfpe.c 
b/mingw-w64-crt/testcases/t_sigfpe.c
new file mode 100644
index 000000000000..eda858d373f9
--- /dev/null
+++ b/mingw-w64-crt/testcases/t_sigfpe.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <assert.h>
+#include <limits.h>
+
+static jmp_buf buf;
+
+static void __attribute__((noreturn)) catch_sigfpe(int signum)
+{
+  printf("SIGFPE exception catched\n");

                              ^^^ caught

English is nonsense, but meh.


+  assert(signum == SIGFPE);
+  longjmp(buf, 1);
+}
+
+int main(void)
+{
+  signal(SIGFPE, catch_sigfpe);
+  if (!setjmp(buf))
+  {
+    puts("execute: INT_MIN/-1");
+    volatile int a = INT_MIN;
+    volatile int b = -1;
+    volatile int c = a / b;

On ARM, the overflow of signed division is ignored, so this test must be 
skipped for ARM.

(https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/SDIV#id19835678)



diff --git a/mingw-w64-crt/testcases/t_sigfpe.c 
b/mingw-w64-crt/testcases/t_sigfpe.c
index eda858d37..61e0e2296 100644
--- a/mingw-w64-crt/testcases/t_sigfpe.c
+++ b/mingw-w64-crt/testcases/t_sigfpe.c
@@ -8,13 +8,17 @@ static jmp_buf buf;

 static void __attribute__((noreturn)) catch_sigfpe(int signum)
 {
-  printf("SIGFPE exception catched\n");
+  printf("SIGFPE exception caught\n");
   assert(signum == SIGFPE);
   longjmp(buf, 1);
 }

 int main(void)
 {
+#if defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__)
+  puts("Division overflow is ignored on ARM");
+  return 77;
+#else
   signal(SIGFPE, catch_sigfpe);
   if (!setjmp(buf))
   {
@@ -28,4 +32,5 @@ int main(void)
   }
   puts("PASSED, program recovered");
   return 0;
+#endif
 }






--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to