This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi, glibc's string/tester and string/inl-tester fail when compiled with Debian's "gcc version 3.2.2 20030109 (Debian prerelease)" on linux-mips (big endian) and -O2 or -Os. I've tried to strip down the testcase as far as possible and suspect that gcc miscompiles it. It works fine with Debian's "gcc version 2.95.4 20011002" and with the above gcc-3.2.2 and optimations turned off, -O3 and -O1: foo@bar:~$ gcc --save-temps -O2 tester.c && ./a.out memccpy flunked test 8 0x10000100 is abcdefghr should be abcdefgh 1 errors. foo@bar:~$ gcc --save-temps -Os tester.c && ./a.out memccpy flunked test 8 0x10000100 is abcdefghr should be abcdefgh 1 errors. foo@bar:~$ gcc --save-temps -O3 tester.c && ./a.out 0x10000100 is abcdefgh should be abcdefgh No errors. foo@bar:~$ gcc --save-temps -O0 tester.c && ./a.out 0x10000100 is abcdefgh should be abcdefgh No errors. foo@bar:~$ gcc -O1 tester.c && ./a.out 0x100000f0 is abcdefgh should be abcdefgh No errors. I've attache the testcase and the assembler output for -O2. Any help greatly appreciated. Regards, -- Guido
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
/* Make sure we don't test the optimized inline functions if we want to
test the real implementation. */
#if !defined DO_STRING_INLINES
#undef __USE_STRING_INLINES
#endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef HAVE_GNU_LD
#define _sys_nerr sys_nerr
#define _sys_errlist sys_errlist
#endif
#define STREQ(a, b) (strcmp((a), (b)) == 0)
const char *it = "memccpy"; /* Routine name for message routines. */
size_t errors = 0;
/* Complain if condition is not true. */
static void
check (int thing, int number)
{
if (!thing)
{
printf("flunked test %d\n", number);
++errors;
}
}
/* Complain if first two args don't strcmp as equal. */
static void
equal (const char *a, const char *b, int number)
{
check(a != NULL && b != NULL && STREQ (a, b), number);
}
char one[50];
char two[50];
static void
test_memccpy (void)
{
(void) strcpy(one, "abcdefgh");
(void) strcpy(two, "horsefeathers");
check(memccpy(two, one, 'f', 9) == two+6, 7); /* Returned value. */
equal(one, "abcdefgh", 8); /* Source intact? */
printf("%p is %s should be abcdefgh\n", one, one);
equal(two, "abcdefeathers", 9); /* Copy correct? */
}
int
main (void)
{
int status;
/* memccpy. */
test_memccpy ();
if (errors == 0)
{
status = EXIT_SUCCESS;
puts("No errors.");
}
else
{
status = EXIT_FAILURE;
printf("%Zd errors.\n", errors);
}
return status;
}
Attachment:
tester-O2.s
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |