List Info

Thread: strange gcc problem - bug?




strange gcc problem - bug?
user name
2006-08-27 15: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.
strange gcc problem - bug?
user name
2006-08-27 15:22:01
aaarrgh!

never mind, this was stupid - missing EOF.

r.
strange gcc problem - bug?
user name
2006-08-27 17:37:02
rudolf wrote:
> never mind, this was stupid - missing EOF.

Not EOF, but 0. I'm sorry. No more posts today!

r.
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )