GCC bug on Linux/Alpha, optimising memcpy()

Martin Kahlert martin.kahlert@mchp.siemens.de
Tue Feb 22 03:14:00 GMT 2000


It seems, that your problem is fixed in gcc 2.95.2
since, i can't reproduce it here.

Martin.

Quoting Jan Wielemaker (jan@swi.psy.uva.nl):
> Hi,
> 
> Please find the problem with description in the file below.  I think
> the two different answers clearly exhibit the problem.  This is a
> minimalised version from a big program I used to make sure it wasn't
> my fault.
> 
> 	Thanks for gcc
> 
> 		Regards --- Jan
> 
> /* gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
>    Linux thor 2.2.13 #1 Sun Nov 28 23:57:27 GMT 1999 alpha unknown
> 
>    Demonstrate:
> 	gcc -O2 -DBUG gccbug.c
> 	./a.out
> 	3400000000000000
> 	gcc -O2 gccbug.c
> 	./a.out
> 	3412000000000000
> */
> 
> #include <stdio.h>
> #include <string.h>
> 
> typedef unsigned long word;
> typedef word atom_t;
> 
> #ifdef BUG 
> #define to p
> #else
> #define to buf
> #endif
> 
> int
> main(int argc, char **argv)
> { char buf[1000];
>   char *p = buf; 
>   word w = 0x1234;
>   int i;
> 
>   memcpy(to, (char *)&w, sizeof(atom_t));
> 
>   for(i=0; i<sizeof(word); i++)
>     printf("%02x", to[i]&0xff);
>   printf("\n");
> 
>   return 0;
> }

-- 
The early bird gets the worm. If you want something else for       
breakfast, get up later.


More information about the Gcc-bugs mailing list