Commit fa1ef887d4dc5d18696517e32e2ae98310f0040d

Anthony Green 2021-06-22T08:48:24

Avoid undefined behaviour

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/testsuite/libffi.bhaible/testcases.c b/testsuite/libffi.bhaible/testcases.c
index d25ebf4..23a6f46 100644
--- a/testsuite/libffi.bhaible/testcases.c
+++ b/testsuite/libffi.bhaible/testcases.c
@@ -64,7 +64,11 @@ typedef struct {
 typedef struct { char c[3]; } T;
 typedef struct { char c[33],c1; } X;
 
-char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1;
+/* Don't use a number over 127, as some systems use signed chars and
+   the test case 25 doesn't account for this, resulting in undefined
+   behavior. See https://github.com/libffi/libffi/issues/598. */
+char c1='a', c2=127, c3=(char)1;
+
 short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9;
 int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9,
     i10=11, i11=12, i12=13, i13=14, i14=15, i15=16, i16=17;