This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[testsuite] Yet another loop failure
- To: gcc-patches at gcc dot gnu dot org
- Subject: [testsuite] Yet another loop failure
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 1 Aug 2000 12:54:30 +0200
- Cc: amylaar at cygnus dot co dot uk, Richard Henderson <rth at cygnus dot com>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
This is miscompiled with -O2 on at least i386 and sparc.
The first part (ie. biv[0] <-> biv[3] is done correctly, but then
loop forgots bp and sp have been changed and biv[1] <-> biv[2] exchange
is done as biv[0] <-> biv[1]. Last biv is correctly incremented by 4.
2000-08-01 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/20000801-1.c: New test.
--- gcc/testsuite/gcc.c-torture/execute/20000801-1.c.jj Tue Aug 1 12:44:09 2000
+++ gcc/testsuite/gcc.c-torture/execute/20000801-1.c Tue Aug 1 12:16:04 2000
@@ -0,0 +1,39 @@
+extern void abort(void);
+extern void exit(int);
+
+void
+foo (char *bp, unsigned n)
+{
+ register char c;
+ register char *ep = bp + n;
+ register char *sp;
+
+ while (bp < ep)
+ {
+ sp = bp + 3;
+ c = *sp;
+ *sp = *bp;
+ *bp++ = c;
+ sp = bp + 1;
+ c = *sp;
+ *sp = *bp;
+ *bp++ = c;
+ bp += 2;
+ }
+}
+
+int main(void)
+{
+ int one = 1;
+
+ if (sizeof(int) != 4 * sizeof(char))
+ exit(0);
+
+ foo((char *)&one, sizeof(one));
+ foo((char *)&one, sizeof(one));
+
+ if (one != 1)
+ abort();
+
+ exit(0);
+}
Jakub