http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48587
--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-04-15 09:13:14 UTC --- Reading the standard, my simple suggestion in #1 will not actually work. One reason is that the NEWUNIT value may not be -1; with my approach this is possible if one first closes fd 1. Secondly, it's possible to reassociate also a negative unit number with a new file; but there is not guarantee that the kernel will assign the same file descriptor to the new file. Wrt. I found a bug in the current implementation, see PR 48618.