title: C++ boost crashes while using locale
body: <p>I am trying to use boost library for providing i18 support to my string class.
  I am using Microsoft Visual studio compiler VC10 and 64 bit Windows 7 machine. </p>
  
  <p>I am able to compile and link my application with the boost library however my application crashes while invoking boost::locale::to_upper().</p>
  
  <p>Following is the code I wrote.</p>
  
  <pre><code>#include &lt;boost/locale.hpp&gt;
  #include &lt;boost/algorithm/string/case_conv.hpp&gt;
  #include &lt;boost/system/config.hpp&gt;
  
  
  
   String::MakeUpper()()
      {
      boost::locale::generator gen;
      std::locale loc = gen("");
      std::locale::global(loc);
      std::string str2 = boost::locale::to_upper("001Öä", loc); // application crashes here.
      std::string str3 = boost::locale::to_upper("001Öä"); // This also does not work
      }
  </code></pre>
  
  <p>The crash happens in the following function. this function throws bad cast exception.</p>
  
  <pre><code>template&lt;class _Facet&gt; inline
  const _Facet&amp; __CRTDECL use_facet(const locale&amp; _Loc)
  
  {   // get facet reference from locale
  _BEGIN_LOCK(_LOCK_LOCALE)   // the thread lock, make get atomic
      const locale::facet *_Psave =
          _Facetptr&lt;_Facet&gt;::_Psave;  // static pointer to lazy facet
  
      size_t _Id = _Facet::id;
      const locale::facet *_Pf = _Loc._Getfacet(_Id);
  
      if (_Pf != 0)
          ;   // got facet from locale
      else if (_Psave != 0)
          _Pf = _Psave;   // lazy facet already allocated
      else if (_Facet::_Getcat(&amp;_Psave, &amp;_Loc) == (size_t)(-1))
  
  #if _HAS_EXCEPTIONS
  
          _THROW_NCEE(bad_cast, _EMPTY_ARGUMENT); // lazy disallowed
  
  ....
  ....
  ....
  
  }
  </code></pre>
  
  <p>Could you please help me out.</p>
  
  <p>Regards,
  Sumit</p>