This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: C++ io, thread safety, and setlocale
- From: John Ruttenberg <rutt at chezrutt dot com>
- To: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- Cc: libstdc++ at gcc dot gnu dot org, bkoz at redhat dot com
- Date: Mon, 21 Apr 2003 22:01:40 -0400
- Subject: Re: C++ io, thread safety, and setlocale
- References: <16036.39784.644352.128004@localhost.localdomain><200304220137.h3M1bOVs038665@latour.rsch.comm.mot.com>
- Reply-to: rutt at chezrutt dot com
Loren James Rittle:
> >I'm still trying to understand why I only have problems on aix and not on
> >linux and solaris.
>
> Without completely knowledge of the libc implementation I could only
> guess. It is possible that Solaris and glibc implement setlocale
> in a manner like FreeBSD where "C" -> "C" is a stable change
> w.r.t. other threads in the process. It is possible that "C"
> is your default locale in all those environments.
>
> It is possible that AIX implements a non-stable setlocale (that
> isn't a bug in their libc since the standard says nothing
> about this). It is possible that you have a non-"C" locale
> in your AIX environment.
>
You are right. My linux box and solaris have a "stable" setlocale. Even
after:
setlocale(LC_ALL,"C");
char* l1 = setlocale(LC_ALL,0);
setlocale(LC_ALL,"C");
char* l2 = setlocale(LC_ALL,strdup(l1)); // Note the strdup
l1 == l2. AIX fails this test. I suppose this explains a lot.
Benjamin suggests moving to gcc-3.3 soon which sounds good. In the meantime,
I think I'll just murder the setlocale's in the generic code.