The DIV instructions of MIPS won't be trapped themself if the divisor
is zero.  The compiler will emit a conditional trap instruct for it.
So the signal will be SIGTRAP instead of SIGFPE.

gcc/testsuite
        * c-c++-common/ubsan/overflow-div-3.c: Use SIGTRAP for MIPS.
---
 gcc/testsuite/c-c++-common/ubsan/overflow-div-3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-div-3.c 
b/gcc/testsuite/c-c++-common/ubsan/overflow-div-3.c
index 479dffb0304..eef58aca832 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-div-3.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-div-3.c
@@ -7,6 +7,11 @@
 #include <stdlib.h>
 
 int cnt;
+#ifdef __mips
+ int sig = SIGTRAP;
+#else
+ int sig = SIGFPE;
+#endif
 
 __attribute__((noipa)) int
 foo (int x, int y)
@@ -30,7 +35,7 @@ main (void)
   sigemptyset (&s.sa_mask);
   s.sa_handler = handler;
   s.sa_flags = 0;
-  sigaction (SIGFPE, &s, NULL);
+  sigaction (sig, &s, NULL);
   volatile int a = foo (42, 0);
   cnt++;
   volatile int b = foo (INT_MIN, -1);
-- 
2.39.3 (Apple Git-146)

Reply via email to