Subject: strange gcc problem - bug?
To: None <netbsd-help@netbsd.org>
From: rudolf <netbsd@eq.cz>
List: netbsd-help
Date: 08/27/2006 17:17:54
Hi,

I have a C code which outputs some extra characters when compiled and 
executed on i386 4.0_BETA and gives correct output on amd64 4.0_BETA 
(both compiled from source around 25.8.2006).

The program could be obtained the following way:

- 8< -
#include <stdio.h>

int
main()
{
   char c;

   printf("#include <stdio.h>\n\n");
   printf("char s[] = {\n\n");
   while ((c = getchar()) != EOF)
     printf("\t%d,\n", c);
   printf("};\n\n");
   printf("int\n");
   printf("main() {\n");
   printf("\tprintf(\"%%s\", s);\n");
   printf("\treturn 0;\n");
   printf("}\n");
   return 0;
}
- >8 -

- let this be a test.c file

$ gcc -o test test.c
$ ./test < test.c > out.c
$ gcc -o out out.c
$ ./out
#include <stdio.h>

int
main()
{
   char c;

   printf("#include <stdio.h>\n\n");
   printf("char s[] = {\n\n");
   while ((c = getchar()) != EOF)
     printf("\t%d,\n", c);
   printf("};\n\n");
   printf("int\n");
   printf("main() {\n");
   printf("\tprintf(\"%%s\", s);\n");
   printf("\treturn 0;\n");
   printf("}\n");
   return 0;
}
XXXX$
^^^^ -- the extra characters

- it should output the original source, but gives extra four characters 
on the end. The characters are (hexadecimal) f0 ff bf bf. I don't get 
these on amd64. Is this a bug in gcc or I have something done wrong 
during the i386 installation/configuration?

Thanks,

r.