* Problem with --disable-c-mbchar and std::tolower
@ 2005-05-18 14:18 Warren_Baird
0 siblings, 0 replies; only message in thread
From: Warren_Baird @ 2005-05-18 14:18 UTC (permalink / raw)
To: gcc-help
We're writing software that was ported from windows to unix, so it assumes
that wchar_t is 2 bytes instead of 4 bytes. We're using the -fshort-wchar
gcc flag, but we've found that creating an std::basic_string of wchar_t
cause all kinds of problems unless we configured gcc with the
"--disable-c-mbchar" option.
This was working fine for quite a while, but recently we discovered that
calling std::tolower on a wchar_t with a locale argument causes a
'bad_cast' exception to be thrown.
Code as simple as the following:
wchar_t c = L'H';
wchar_t c1 = std::tolower(c, std::locale());
will generate the bad_cast exception.
What seems to be happening is that the use_facet code is looking at
ctype<wchar_t>::_M_id(), finding that it is out of range ( it's greater
than locale's _M_impl->_M_facets_size), and throwing the exception. I'm
assuming this is happening because "--disable-c-mbchar" is setting things
up so that the wchar_t info isn't in the list of facets.
Any suggestions on how to resolve this? The plans I'm considering are to
find the STL code that adds the wchar_t info to the facet list and
reintroducing it manually, or to turn off the disable-c-mbchar
configuration option, and try to get things working like that. But I
must admit neither option sounds ideal to me, so I'd appreciate other
suggestions.
I've tested this with both gcc 3.4.2 and 4.0.0 on linux/x86, Solaris
9/sparc and HPUX11/pa-risc and I get the same behaviour everywhere - if
the "--disable-c-mbchar" configuration option is used.
Warren,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-18 14:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-18 14:18 Problem with --disable-c-mbchar and std::tolower Warren_Baird
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).