This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Unable to bootstrap gcc snapshot of 20001211 on Dynix/ptx
- To: jsm28 at cam dot ac dot uk, robertlipe at usa dot net
- Subject: RE: Unable to bootstrap gcc snapshot of 20001211 on Dynix/ptx
- From: biswapesh dot chattopadhyay at bt dot com
- Date: Mon, 18 Dec 2000 17:20:32 -0000
- Cc: janis at us dot ibm dot com, gcc at gcc dot gnu dot org
> According to the Single Unix Specification, bcopy must handle
> overlapping
> memory.
>
There definitely is a bug in bcopy in Dynix/ptx 4.4.8 then, and I've got a
testcase ready. Here is the code:
-----------------------------------------------------------------
#include <string.h>
#ifdef USE_BCOPY
#define BUF "Native bcopy"
#include <strings.h>
#else
#ifndef USE_MEMMOVE
/* This is the GNU implementation found in libinerty/bcopy.c */
void bcopy (src, dest, len)
register char *src, *dest;
int len;
{
if (dest < src)
while (len--)
*dest++ = *src++;
else
{
char *lasts = src + (len-1);
char *lastd = dest + (len-1);
while (len--)
*(char *)lastd-- = *(char *)lasts--;
}
}
#define BUF "GNU bcopy"
#else
#define bcopy(A,B,C) memmove((B), (A), (C))
#define BUF "Memmove"
#endif
#endif
int main()
{
char *str = strdup("Test string");
bcopy(str, str + 2, 6);
printf("%s: %s\n", BUF, str);
}
-------------------------------------------------------------------------
Here is the output:
----------------------------------------
/usr/home/swbxc01/cpp>gcc -DUSE_BCOPY -o test1 test1.c
/usr/home/swbxc01/cpp>./test1
Native bcopy: TeTeststing
/usr/home/swbxc01/cpp>gcc -o test1 test1.c
/usr/home/swbxc01/cpp>./test1
GNU bcopy: TeTest sing
/usr/home/swbxc01/cpp>gcc -DUSE_MEMMOVE -o test1 test1.c
/usr/home/swbxc01/cpp>./test1
Memmove: TeTest sing
--------------------------------------------
So, GNU bcopy and memmove do the correct thing, ptx native bcopy comes up
with a diferent (wrong) string. Janis, can you test this in ptx 4.6.0 to see
if the bug has been corrected ? This might explain why you were able to
compile gcc without the cp/class.c BCOPY patch.
It might be a good idea to incorporate a test somewhat like this one in
autoconf to check for buggy bcopy and disable (substitute it with the
libiberty version/memmove) accordingly. Another idea might be not to use
bcopy for overlapping memory regions (I went through the instances of bcopy
and cp/class.c seems to be the only candidate.)
Rgds.
Biswa