This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81138] New: std::money_put facet does not write '0' before decimal point
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Jun 2017 11:58:32 +0000
- Subject: [Bug libstdc++/81138] New: std::money_put facet does not write '0' before decimal point
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81138
Bug ID: 81138
Summary: std::money_put facet does not write '0' before decimal
point
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout.imbue(locale("en_US"));
cout << showbase;
cout << put_money(99);
cout << '\n';
}
This prints $.99 rather than $0.99
This happens for all locales with with non-zero moneypunct<>::frac_digits().
The following untested patch fixes it, but I don't know if it breaks other
locales:
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -471,6 +471,8 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
else
__value.assign(__beg, __paddec);
}
+ else
+ __value.assign(1, __lit[money_base::_S_zero]);
// Deal with decimal point, decimal digits.
if (__lc->_M_frac_digits > 0)