[Bug c++/81137] New: std::put_money doesn't output zero value correctly

jonathan.r.paton at googlemail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 20 11:48:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81137

            Bug ID: 81137
           Summary: std::put_money doesn't output zero value correctly
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jonathan.r.paton at googlemail dot com
  Target Milestone: ---

Sent from stack overflow, first report here so apologies in advance if I've
done anything incorrectly.

When using std::put_money to output a value of zero, I'd expect it to be
correctly, formatted, e.g. for GBP I'd expect "£0.00", however the actual
output is "£.00"

Personally I noticed this on version 4.9, however I've had reports that the
same behaviour is seen on 5.0, 6.3, and a handful of other versions. It also
appears that clang and the VS compiler behave differently and output the
expected string.

Code to reproduce:

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    cout.imbue(locale(""));
    cout << showbase << put_money(0.0);
    return 0;
}


More information about the Gcc-bugs mailing list