https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79820

            Bug ID: 79820
           Summary: std::ifstream sets errno to zero
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m-ou...@m-ou.se
  Target Milestone: ---

https://gcc.gnu.org/onlinedocs/libstdc++/manual/errno.html says errno is never
set to zero by libstdc++:

"The C and POSIX standards guarantee that errno is never set to zero by any
library function. The C++ standard has less to say about when errno is or isn't
set, but libstdc++ follows the same rule and never sets it to zero."

However, libstdc++-v3/config/io/basic_file_stdio.cc sets errno to zero in
__basic_file<char>::sys_open (currently line 199). I guess errno is set to zero
because sync() two lines below isn't guaranteed to update errno, in which case
the loop might run forever if errno happened to be EINTR.

Maybe errno should only be set to zero in the case when it is EINTR, the only
problematic case, and left untouched otherwise.

Reply via email to