Update on libstdc++/6410 (a.k.a. non-ascii mon. symbol AND wchar_t => chaos)
Paolo Carlini
pcarlini@unitus.it
Tue May 7 06:01:00 GMT 2002
Hi,
I'm trying to understand what is really going on. Benjamin provided the
following patch, which essentially, at the cost of breaking the 3.1 API
would solve the problem diagnosed with the help of Ulrich:
http://gcc.gnu.org/ml/gcc-prs/2002-05/msg00151.html
I have applied it and verified that indeed does what it was supposed to
do: at inizialization time mbsrtowcs does the right thing thanks to the
usual MT-unsafe setlocale -- setlocale scheme: i.e., with the patch
applied the testcase below does the *same* thing with and without the
setlocale line.
#include <locale>
#include <sstream>
#include <cassert>
int main()
{
using namespace std;
typedef ostreambuf_iterator<wchar_t> iterator_type;
// setlocale(LC_ALL, "de_DE@euro");
locale loc_de("de_DE@euro");
const wstring empty;
const wstring digits1(L"720000000000");
wostringstream oss;
oss.imbue(loc_de);
const money_put<wchar_t>& mon_put = use_facet<money_put<wchar_t>
>(oss.getloc());
oss.setf(ios_base::showbase);
oss.str(empty);
iterator_type os_it04 = mon_put.put(oss.rdbuf(), false, oss, ' ',
digits1);
wstring result4 = oss.str();
assert( result4 == L"7.200.000.000,00 \244");
}
How did I ascertain this? By putting a breakpoint in the assert and
following the execution until the wmemcmp call.
Now, however, what's happening is that the assert still fails, since
result4, while being different from that of the unpatched case (in the
unpatched case, even n == 17), is still not correct:
23 int
24 wmemcmp (s1, s2, n)
25 const wchar_t *s1;
26 const wchar_t *s2;
27 size_t n;
28 {
29 register wint_t c1;
30 register wint_t c2;
(gdb) print n
$1 = 18
(gdb) print *(s1 + 17)
$2 = 8364
(gdb) print *(s2 + 17)
$3 = 164
Any idea useful to make some further progress?
Thanks for the attention,
Paolo.
More information about the Libstdc++
mailing list