b2562e14   
   From: v.haisman@sh.cvut.cz   
      
   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 and do std::memset (&mystate, 0, sizeof(mystate));:   
      
      
   // codecvt::out example   
   #include    
   #include    
   #include    
   #include // XXX   
      
   using namespace std;   
      
   int main ()   
   {   
    locale mylocale;   
    mbstate_t mystate;   
      
    wstring mywstring;   
      
    const codecvt& myfacet =   
    use_facet >(mylocale);   
      
    codecvt::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::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! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|