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]

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


Paolo Carlini wrote:
>   std::basic_ofstream<int, std::char_traits<int> > out;
[...]
>   out.write(&i, 1);
[...]
> 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.

The standard says that codecvt must be obtained "as if" by:

  codecvt<charT,char,typename traits::state_type> a_codecvt =
    use_facet<codecvt<charT,char,typename traits::state_type> >(getloc());

This fragment will cause bad_cast to be thrown if getloc() doesn't
contain the correct codecvt, so it seems that the current behaviour is
required by the standard.

Petur



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