Browse code

add testcase for gcc bug 37573, affecting gcc 4.1.2 at -O3 too (bb #1258)

git-svn: trunk@4302

Török Edvin authored on 2008/10/30 04:06:09
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Wed Oct 29 20:52:07 EET 2008 (edwin)
2
+------------------------------------
3
+ * configure, configure.in: add testcase for gcc bug 37573, affecting
4
+ gcc 4.1.2 at -O3 too (bb #1258)
5
+
1 6
 Tue Oct 28 22:08:19 EET 2008 (edwin)
2 7
 ------------------------------------
3 8
  * unit_tests/valgrind.supp: fix more valgrind warnings
... ...
@@ -12556,6 +12556,130 @@ fi
12556 12556
 
12557 12557
 
12558 12558
 
12559
+{ echo "$as_me:$LINENO: checking for gcc bug PR37573" >&5
12560
+echo $ECHO_N "checking for gcc bug PR37573... $ECHO_C" >&6; }
12561
+if test "$cross_compiling" = yes; then
12562
+  { echo "$as_me:$LINENO: result: cross-compiling, assumed ok" >&5
12563
+echo "${ECHO_T}cross-compiling, assumed ok" >&6; }
12564
+else
12565
+  cat >conftest.$ac_ext <<_ACEOF
12566
+/* confdefs.h.  */
12567
+_ACEOF
12568
+cat confdefs.h >>conftest.$ac_ext
12569
+cat >>conftest.$ac_ext <<_ACEOF
12570
+/* end confdefs.h.  */
12571
+
12572
+struct S
12573
+{
12574
+  unsigned int *a;
12575
+  unsigned int b;
12576
+  unsigned int c[624];
12577
+};
12578
+static unsigned char
12579
+foo (struct S *s)
12580
+{
12581
+  unsigned int r;
12582
+  if (!--s->b)
12583
+    {
12584
+      unsigned int *c = s->c;
12585
+      unsigned int i;
12586
+      s->a = c;
12587
+      for (i = 0; i < 227; i++)
12588
+	c[i] =
12589
+	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
12590
+	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];
12591
+      for (; i < 623; i++)
12592
+	c[i] =
12593
+	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
12594
+	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i - 227];
12595
+      c[623] =
12596
+	((((c[623] ^ c[0]) & 0x7ffffffe) ^ c[623]) >> 1) ^ ((0 - (c[0] & 1)) &
12597
+							    0x9908b0df) ^ c[i
12598
+									    -
12599
+									    227];
12600
+    }
12601
+  r = *(s->a++);
12602
+  r ^= (r >> 11);
12603
+  r ^= ((r & 0xff3a58ad) << 7);
12604
+  r ^= ((r & 0xffffdf8c) << 15);
12605
+  r ^= (r >> 18);
12606
+  return (unsigned char) (r >> 1);
12607
+}
12608
+
12609
+void
12610
+bar (unsigned char *p, unsigned int q, unsigned int r)
12611
+{
12612
+  struct S s;
12613
+  unsigned int i;
12614
+  unsigned int *c = s.c;
12615
+  *c = r;
12616
+  for (i = 1; i < 624; i++)
12617
+    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);
12618
+  s.b = 1;
12619
+  while (q--)
12620
+    *p++ ^= foo (&s);
12621
+};
12622
+
12623
+static unsigned char p[23] = {
12624
+  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,
12625
+    0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38
12626
+};
12627
+
12628
+static unsigned char q[23] = {
12629
+  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,
12630
+    0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c
12631
+};
12632
+
12633
+int
12634
+main (void)
12635
+{
12636
+  unsigned int s;
12637
+  s = 23;
12638
+  bar (p, s, s + 0xa25e);
12639
+  if (__builtin_memcmp (p, q, s) != 0)
12640
+    __builtin_abort ();
12641
+  return 0;
12642
+}
12643
+
12644
+
12645
+_ACEOF
12646
+rm -f conftest$ac_exeext
12647
+if { (ac_try="$ac_link"
12648
+case "(($ac_try" in
12649
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12650
+  *) ac_try_echo=$ac_try;;
12651
+esac
12652
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12653
+  (eval "$ac_link") 2>&5
12654
+  ac_status=$?
12655
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
12656
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
12657
+  { (case "(($ac_try" in
12658
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12659
+  *) ac_try_echo=$ac_try;;
12660
+esac
12661
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12662
+  (eval "$ac_try") 2>&5
12663
+  ac_status=$?
12664
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
12665
+  (exit $ac_status); }; }; then
12666
+  { echo "$as_me:$LINENO: result: ok, bug not present" >&5
12667
+echo "${ECHO_T}ok, bug not present" >&6; }
12668
+else
12669
+  echo "$as_me: program exited with status $ac_status" >&5
12670
+echo "$as_me: failed program was:" >&5
12671
+sed 's/^/| /' conftest.$ac_ext >&5
12672
+
12673
+( exit $ac_status )
12674
+{ { echo "$as_me:$LINENO: error: your compiler has gcc PR37573 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37573" >&5
12675
+echo "$as_me: error: your compiler has gcc PR37573 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37573" >&2;}
12676
+   { (exit 1); exit 1; }; }
12677
+fi
12678
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
12679
+fi
12680
+
12681
+
12682
+
12559 12683
 { echo "$as_me:$LINENO: checking for ld --version-script" >&5
12560 12684
 echo $ECHO_N "checking for ld --version-script... $ECHO_C" >&6; }
12561 12685
 if test "${ac_cv_ld_version_script+set}" = set; then
... ...
@@ -243,6 +243,87 @@ int main (void)
243 243
 ], [AC_MSG_RESULT([ok, bug not present])],
244 244
 [AC_MSG_ERROR([your compiler has gcc PR28045 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28045])], [AC_MSG_RESULT([cross-compiling, assumed ok])])
245 245
 
246
+dnl Check if compiler produces invalid code on gcc PR37573 (affects autoit.c)
247
+dnl this is a bug in gcc 4.4.0, but for some reason it affects gcc 4.1.2 too
248
+dnl gcc 4.1.3 is OK. This bug occurs only at -O3.
249
+AC_MSG_CHECKING([for gcc bug PR37573])
250
+AC_TRY_RUN(
251
+	   [
252
+struct S
253
+{
254
+  unsigned int *a;
255
+  unsigned int b;
256
+  unsigned int c[624];
257
+};
258
+static unsigned char
259
+foo (struct S *s)
260
+{
261
+  unsigned int r;
262
+  if (!--s->b)
263
+    {
264
+      unsigned int *c = s->c;
265
+      unsigned int i;
266
+      s->a = c;
267
+      for (i = 0; i < 227; i++)
268
+	c[i] =
269
+	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
270
+	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];
271
+      for (; i < 623; i++)
272
+	c[i] =
273
+	  ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) ^
274
+	  ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i - 227];
275
+      c[623] =
276
+	((((c[623] ^ c[0]) & 0x7ffffffe) ^ c[623]) >> 1) ^ ((0 - (c[0] & 1)) &
277
+							    0x9908b0df) ^ c[i
278
+									    -
279
+									    227];
280
+    }
281
+  r = *(s->a++);
282
+  r ^= (r >> 11);
283
+  r ^= ((r & 0xff3a58ad) << 7);
284
+  r ^= ((r & 0xffffdf8c) << 15);
285
+  r ^= (r >> 18);
286
+  return (unsigned char) (r >> 1);
287
+}
288
+
289
+void
290
+bar (unsigned char *p, unsigned int q, unsigned int r)
291
+{
292
+  struct S s;
293
+  unsigned int i;
294
+  unsigned int *c = s.c;
295
+  *c = r;
296
+  for (i = 1; i < 624; i++)
297
+    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);
298
+  s.b = 1;
299
+  while (q--)
300
+    *p++ ^= foo (&s);
301
+};
302
+
303
+static unsigned char p[23] = {
304
+  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,
305
+    0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38
306
+};
307
+
308
+static unsigned char q[23] = {
309
+  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,
310
+    0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c
311
+};
312
+
313
+int
314
+main (void)
315
+{
316
+  unsigned int s;
317
+  s = 23;
318
+  bar (p, s, s + 0xa25e);
319
+  if (__builtin_memcmp (p, q, s) != 0)
320
+    __builtin_abort ();
321
+  return 0;
322
+}
323
+
324
+], [AC_MSG_RESULT([ok, bug not present])],
325
+[AC_MSG_ERROR([your compiler has gcc PR37573 bug, use a different compiler, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37573])], [AC_MSG_RESULT([cross-compiling, assumed ok])])
326
+
246 327
 dnl Linker feature checks
247 328
 dnl check for version script support in the linker (GNU ld, or Solaris ld style)
248 329
 AC_CACHE_CHECK([for ld --version-script], [ac_cv_ld_version_script], [dnl