This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9322: return value of basic_streambuf<>::getloc affected by locale::global
- From: peturr02 at ru dot is
- To: gcc-gnats at gcc dot gnu dot org
- Date: 15 Jan 2003 10:48:25 -0000
- Subject: libstdc++/9322: return value of basic_streambuf<>::getloc affected by locale::global
- Reply-to: peturr02 at ru dot is
>Number: 9322
>Category: libstdc++
>Synopsis: return value of basic_streambuf<>::getloc affected by locale::global
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 15 02:56:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
If basic_streambuf<>::pubimbue() has not been called, the value returned by basic_streambuf<>::getloc() is the current global locale at the time getloc() is called, not the current global locale at the time of construction.
In particular, this means that it is not possible to cache the results of use_facet<>(getloc()), as the lifetime of the locale returned by getloc() is unknown.
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="imbuebug.cc"
Content-Disposition: inline; filename="imbuebug.cc"
#include <locale>
#include <streambuf>
using namespace std;
class Mybuf : public streambuf
{
};
#undef NDEBUG
#include <cassert>
int main()
{
Mybuf buf;
locale loc1 = buf.getloc();
locale::global(locale(""));
locale loc2 = buf.getloc();
assert(loc1 == loc2);
return 0;
}