aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-11-19 00:01:35 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-11-19 00:01:35 +0100
commit890154a8b65532d96f4853ca32d98b6e555ffa21 (patch)
treea106c282f6a5c669c8fba459b5fb1a5822731d18 /gcc
parent042fed7915f1e924be61128d6409ad3eee2fe0a2 (diff)
downloadgcc-890154a8b65532d96f4853ca32d98b6e555ffa21.zip
gcc-890154a8b65532d96f4853ca32d98b6e555ffa21.tar.gz
gcc-890154a8b65532d96f4853ca32d98b6e555ffa21.tar.bz2
re PR tree-optimization/38051 (Miscompilation of glibc's memcmp)
PR tree-optimization/38051 * gcc.c-torture/execute/pr38051.c (buf): Remove aligned attribute. (buf2): Removed. (main): Only run on little endian targets with sizeof (long) == sizeof (void *). Use just one buffer, align the pointers at runtime. From-SVN: r141983
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr38051.c22
2 files changed, 25 insertions, 6 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a2b3096..4f49d7f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2008-11-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/38051
+ * gcc.c-torture/execute/pr38051.c (buf): Remove aligned attribute.
+ (buf2): Removed.
+ (main): Only run on little endian targets with
+ sizeof (long) == sizeof (void *). Use just one buffer, align the
+ pointers at runtime.
+
2008-11-18 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/38135
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr38051.c b/gcc/testsuite/gcc.c-torture/execute/pr38051.c
index 3437f73..e3b6dd9 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr38051.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr38051.c
@@ -188,18 +188,28 @@ int mymemcmp (const void *s1, const void *s2, size_t len)
return mymemcmp3 (srcp1, srcp2, len / (sizeof (unsigned long int)));
}
-char buf[256] __attribute__((aligned (16)));
-char buf2[256] __attribute__((aligned (16)));
+char buf[256];
int
main (void)
{
- __builtin_memcpy (buf + 9,
+ char *p;
+ union { long int l; char c[sizeof (long int)]; } u;
+
+ /* The test above assumes little endian and long being the same size
+ as pointer. */
+ if (sizeof (long int) != sizeof (void *) || sizeof (long int) < 4)
+ return 0;
+ u.l = 0x12345678L;
+ if (u.c[0] != 0x78 || u.c[1] != 0x56 || u.c[2] != 0x34 || u.c[3] != 0x12)
+ return 0;
+
+ p = buf + 16 - (((long int) buf) & 15);
+ __builtin_memcpy (p + 9,
"\x1\x37\x82\xa7\x55\x49\x9d\xbf\xf8\x44\xb6\x55\x17\x8e\xf9", 15);
- __builtin_memcpy (buf2 + 24,
+ __builtin_memcpy (p + 128 + 24,
"\x1\x37\x82\xa7\x55\x49\xd0\xf3\xb7\x2a\x6d\x23\x71\x49\x6a", 15);
- if (mymemcmp (buf + 9, buf2 + 24, 33) != -51)
+ if (mymemcmp (p + 9, p + 128 + 24, 33) != -51)
__builtin_abort ();
return 0;
}
-