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)