Compile this test program with "cc":
int real_position = lseek(fileno(stdin), 0, SEEK_CUR);
int stdio_position = ftell(stdin);
printf("really = %d, stdio = %d\n", real_position, stdio_position);
Then run "(cat >/dev/null; ./a.out) < foo", where "foo" is any non-empty
file. It will print two identical numbers for "really" and "identical".
Now compile the same test program, this time using "c++" instead of "cc".
This time, when you run the same test command, the "stdio" number will be 0
instead of matching the "really" number.
In short, ftell() in libstdc++ is not doing the right thing if the file
descriptor is at a non-zero position before stdio gets its hands on it.
This has real ramifications. For one thing, it broke ghostscript (see bug
52505, which I just filed about this).
assigning to jakub, I have no idea why the bug did end up being assigned to
This was fixed in libstdc++-2.96-98 on 2001-09-04.