[Boost-bugs] [Boost C++ Libraries] #11878: Locale dependend number formatting doesn't work with MSVC release config

Subject: [Boost-bugs] [Boost C++ Libraries] #11878: Locale dependend number formatting doesn't work with MSVC release config
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-12-29 18:53:18


#11878: Locale dependend number formatting doesn't work with MSVC release config
-------------------------------+---------------------
 Reporter: octavian.cacina@… | Owner: artyom
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: locale
  Version: Boost 1.60.0 | Severity: Problem
 Keywords: |
-------------------------------+---------------------
 I have this Problem on Windows with Visual Studio 2015 and boost 1.60.
 The formatting of float numbers is not working properly, when using
 Release configuration with dynamic runtime. The Debug configuration or the
 Release with static runtime work as expected. This can be quite a show
 stopper if one is relying on boost::locale for number formatting.

 For a german locale the number must be formatted as "2,14". In Release
 config is formatted as "2.14"

 Here is the test code and the output for Debug and Release.

 {{{#!c++
 #include <locale>
 #include <string>
 #include <iostream>

 #include "boost/locale.hpp"

 int main()
 {
   using namespace std;

   float v = 2.14f;

   // Use std locale to format a float

   auto stdLocale = std::locale("German_germany");
   cout.imbue(stdLocale);
   cout << "std locale " << v << endl;

   auto& stdNumPunct = std::use_facet<std::numpunct<char>>(stdLocale);
   cout << "std locale decimal_point " << stdNumPunct.decimal_point() <<
 endl;

   cout << "std locale num_put ";
   auto& stdFacet = std::use_facet<std::num_put<char>>(stdLocale);
   stdFacet.put(cout, cout, '0', v);
   cout << endl;

   // Use boost locale to format a float

   boost::locale::generator gen;
   auto boostLocale = gen("de_DE.UTF-8");
   cout.imbue(boostLocale);

   cout << "boost locale " << boost::locale::as::number << v << endl;

   auto& boostNumPunct = std::use_facet<std::numpunct<char>>(boostLocale);
   cout << "boost locale decimal_point " << boostNumPunct.decimal_point()
 << endl;

   cout << "boost locale num_put ";
   auto& boostFacet = std::use_facet<std::num_put<char>>(boostLocale);
   boostFacet.put(cout, cout, '0', v);
   cout << endl;

   return 0;
 }

 }}}


 {{{
 ...\Debug> LocaleNumPunct.exe
 std locale 2,14
 std locale decimal_point ,
 std locale num_put 2,14
 boost locale 2,14
 boost locale decimal_point ,
 boost locale num_put 2,14

 ...\Release>LocaleNumPunct.exe
 std locale 2,14
 std locale decimal_point ,
 std locale num_put 2,14
 boost locale 2.14
 boost locale decimal_point ,
 boost locale num_put 2.14
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11878>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC