Hi,

I reported this failure earlier today in
https://gcc.gnu.org/pipermail/gcc-patches/2026-November/738737.html

Tonight, I had some more spare time, so I took another look and checked what
the test is really testing. I don't know why -1/-1 was selected, but since 0/-1
is the only valid expression (the only one without UB), I suppose we can change
to that.

Tested on arm-none-eabi, using r17-6056-g9adb420e4826a6 as the baseline.

Ok for trunk?

Kind regards,
Torbjörn

--

For signed _BitInt(1), 0 / -1 is the only division that does not
have undefined behavior.

gcc/testsuite/ChangeLog:

        * gcc.dg/torture/bitint-97.c: Avoid undefined behavior.

Signed-off-by: Torbjörn SVENSSON <[email protected]>
---
 gcc/testsuite/gcc.dg/torture/bitint-97.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/torture/bitint-97.c 
b/gcc/testsuite/gcc.dg/torture/bitint-97.c
index 58c5e9ea27d..9650da511ca 100644
--- a/gcc/testsuite/gcc.dg/torture/bitint-97.c
+++ b/gcc/testsuite/gcc.dg/torture/bitint-97.c
@@ -20,14 +20,14 @@ main ()
 {
   _BitInt(1) e[8];
   _BitInt(1) f[8] = {
-    -1, 0, -1, 0, 0, -1, -1, -1,
+    -1, 0, 0, 0, 0, -1, -1, -1,
   };
   signed _BitInt(1) g[8] = {
     -1, -1, -1, -1, -1, 0, 0, -1,
   };
   bar (e, f, g);
   _BitInt(1) h[8] = {
-    0, -1, -1, -1, 0, 0, -1, -1
+    0, -1, 0, -1, 0, 0, -1, -1
   };
   for (int i = 0; i < 8; ++i)
     if (e[i] != h[i] || (i > 2 && f[i] != g[i]))
-- 
2.43.0

Reply via email to