This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: ofstream, fsync and data loss bugs
On 17 March 2010 19:10, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> On 03/17/2010 07:35 PM, Pavel Sanda wrote:
>> Is there some "bugzilla" for ISO C++ Standard? :)
> Sure, PRs are normally called Defect Reports or Issues. See:
>
> ? ?http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html
>
> If, after having throughly discussed the issue either on, say,
> comp.std.c++ or the ISO C++ library reflector, you are sure there is a
> bug in the Standard, just send a message to Hinnant, library Chair, and
> ask for an issue to be opened.
>
> But note that this is not an appropriate place for that kind of discussion.
>
> Anyway, in passing, I note that neither fsync nor sync are part of the C
> standard (which normally is the reference in C++ for specifying various
> bits of the semantics of the file streams), thus, naively, something
> seems fishy about the very way of approaching the issue...
It's an interesting problem, if not a new one. There is no way to
fsync in portable C, you have to use fileno to get a descriptor from a
FILE* ... but if you're in a POSIX environment you know you can do
that. The problem in C++ is similar, except there's not even a
portable way to get a "native handle" which can then be used with with
fsync (via fileno if necessary.)
The new C++ standard acknowledges the existence of POSIX and the
threading components provide implementation-defined ways to access
non-portable native handles, it's a shame we didn't revisit iostreams
to do something similar. I don't have a good answer, and it's too late
to deal with it for C++1x.