Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++.moderated > #1367
| From | Vaclav Haisman <v.haisman@sh.cvut.cz> |
|---|---|
| Newsgroups | comp.lang.c++.moderated |
| Subject | Re: codecvt problem |
| Date | 2011-06-05 21:41 -0600 |
| Organization | Czech Technical University |
| Message-ID | <4DEBC922.2060901@sh.cvut.cz> (permalink) |
| References | <3fe789b8-a729-4623-9e7e-301984e6c053@z13g2000yqg.googlegroups.com> |
Rafał Moniuszko wrote, On 5.6.2011 15:25:
[...]
> ==9451== Conditional jump or move depends on uninitialised value(s)
I think that this is likely because of uninitialized mystate variable. Add
#include <cstring> and do std::memset (&mystate, 0, sizeof(mystate));:
// codecvt::out example
#include <iostream>
#include <locale>
#include <string>
#include <cstring> // XXX
using namespace std;
int main ()
{
locale mylocale;
mbstate_t mystate;
wstring mywstring;
const codecvt<wchar_t,char,mbstate_t>& myfacet =
use_facet<codecvt<wchar_t,char,mbstate_t> >(mylocale);
codecvt<wchar_t,char,mbstate_t>::result myresult;
cout << "Enter sentence: ";
getline (wcin,mywstring);
size_t length = mywstring.length();
char* pstr= new char [length+1];
const wchar_t* pwc;
char* pc;
std::memset (&mystate, 0, sizeof(mystate)); // XXX
// translate characters:
myresult = myfacet.out (mystate,
mywstring.c_str(), mywstring.c_str()+length+1, pwc,
pstr, pstr+length+1, pc);
if ( myresult == codecvt<wchar_t,char,mbstate_t>::ok )
cout << "Translation successful: " << pstr << endl;
return 0;
}
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to comp.lang.c++.moderated | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
codecvt problem Rafał Moniuszko <rafal.lists@gmail.com> - 2011-06-05 07:25 -0600
Re: codecvt problem Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-05 21:41 -0600
Re: codecvt problem Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-06-06 12:50 -0600
Re: codecvt problem Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-06 15:31 -0600
Re: codecvt problem Martin Bonner <martinfrompi@yahoo.co.uk> - 2011-06-08 02:06 -0600
Re: codecvt problem Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-08 17:24 -0600
Re: codecvt problem Seungbeom Kim <musiphil@bawi.org> - 2011-06-09 07:02 -0600
Re: codecvt problem Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-06-16 17:04 -0600
Re: codecvt problem Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-06-17 06:42 -0600
Re: codecvt problem Seungbeom Kim <musiphil@bawi.org> - 2011-06-18 07:38 -0600
Re: codecvt problem Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-06-20 13:16 -0600
Re: codecvt problem Seungbeom Kim <musiphil@bawi.org> - 2011-06-23 14:42 -0600
Re: codecvt problem Seungbeom Kim <musiphil@bawi.org> - 2011-06-09 07:01 -0600
Re: codecvt problem Daniel Krügler <daniel.kruegler@googlemail.com> - 2011-06-06 15:31 -0600
Re: codecvt problem Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-06-07 03:07 -0600
Re: codecvt problem Daniel Krügler <daniel.kruegler@googlemail.com> - 2011-06-07 10:31 -0600
Re: codecvt problem Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-06-06 12:47 -0600
csiph-web