This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] A QoI problem with filebuf and POD charT != char, wchar_t


Hi,

today I was reading a message on comp.lang.c++.moderated and noticed
something that seems a serious QoI problem. Consider this:

 std::basic_ofstream<int, std::char_traits<int> > out;
 out.open("out");

int i = -10;

 out.write(&i, 1);
 assert( out.good() );

 out.put(i);
 assert( out.good() );

 out.close();
 assert (out.good());

now (at variance with 3.3.x) this kind of testcase compiles as-is,
but, unfortunately, doesn't run as I had hoped :(

In particular both the 'write' and the 'close' fail. Why?

Basically, because of this kind of check

__check_facet(_M_codecvt).always_noconv()

present both in xsputn and in _M_convert_to_external (and in underflow):
_M_codecvt is a NULL pointer for charT == int and __check_facet throws.

I definitely believe we can improve that, since, basically, all the bits
necessary to deal correctly with a generic POD charT are already there.

Ideas, suggestions??

Thanks,
Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]