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: [PATCH] codecvt<wchar_t, char, mbstate_t> support for UTF-8


Benjamin Kosnik wrote:
> >You are of course right that MB_CUR_MAX is not thread-safe in general
> >(since it depends on the global locale set by setlocale). 
> This however
> >seems to be a general problem with the generic locale implementation
> >(including codecvt<wchar_t, char, mbstate_t>::do_in and do_out).
> 
> This is also correct.

Well, actually the use of MB_CUR_MAX in do_encoding is not thread-unsafe
per se, it is simply unsafe :-) One usage for MB_CUR_MAX is to calculate
buffer sizes for do_out, if setlocale is called between do_encoding and
do_out, the buffer size may be wrong. It doesn't matter if setlocale is
called from the same thread or from a different one.

Regards,
Petur


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