------- Comment #5 from pcarlini at suse dot de  2007-03-12 18:51 -------
(In reply to comment #4)
> Perhaps there are different degrees of thread safety here.
> 
> If I write my multi-threaded program such that only one thread does stream I/O
> with libstdc++, I would expect it to operate safely with respect to the locale
> issue. But it will not: any other thread which modifies errno (via set_errno)
> is potential trouble for my stream I/O thread.

That's not correct. Anyone, anywhere, irrespective of I/O can do a "setlocale"
and that will change the global locale, which is also changed in a
thread-unsafe way at any I/O. 

Anyway, what happens in the GNU systems is that errno is a per-thread variable
and the __convert_to_v code has to do nothing special, just safely use it. In
the systems using the generic locale model a completely different strategy is
needed if the C library of those systems doesn't provide a thread-safe
implementation. I have no idea what that can be and in any case must be solved
together with the setlocale one.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31117

Reply via email to