[RFC] A QoI problem with filebuf and POD charT != char, wchar_t
Paolo Carlini
pcarlini@suse.de
Mon May 17 13:32:00 GMT 2004
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.
More information about the Libstdc++
mailing list