This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: stderr vs. STDERR_FILENO
Jonathan Lennox <lennox@cs.columbia.edu> writes:
| Zack Weinberg <zack at codesourcery dot com> writes:
| > For what it's worth I think this is primarily a documentation issue -
|
| It just occured to me -- no, unfortunately, this is a correctness issue.
|
| This C++ program is well-defined by the standard -- it invokes
| std::terminate, which invokes abort().
|
| #include <cstdio>
| #include <stdexcept>
|
| int main()
| {
| std::fclose(stderr);
|
| throw std::runtime_error("Boom!");
| }
|
| However, given a general-purpose C library which complies only with the
| requirements of the C/C++ standards, __gnu_cxx::__verbose_terminate_handler
| invokes undefined behavior on this program.
Which would strongly argue for keeping file descriptor 2.
-- Gaby