http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51288
Bug #: 51288 Summary: get_money implementation is missing the sentry object (does not skip leading whitespace) Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: cu...@cubbi.org The I/O manipulator std::get_money, as implemented so far, fails to skip leading whitespace: #include <iostream> #include <sstream> #include <locale> #include <iomanip> int main() { std::string str = " $1.23"; std::istringstream s1(str); try { s1.imbue(std::locale("en_US.UTF-8")); long double val; s1 >> std::get_money(val); if(s1) std::cout << val << '\n'; else std::cout << "Bug\n"; } catch(...) { std::cout << "Missing locale en_US.UTF-8, cannot run this test\n"; } } g++ 4.7.0 20111105 output: Bug clang++ 2.9/libc++-svn output: 123 The cause: GCC implementation of operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f) calls __mg.get right away, but the standard says §27.7.5/1 "The expression in >> get_money(mon, intl) described below behaves as a formatted input function (27.7.2.2.1)." §27.7.2.2.1/1 "Each formatted input function begins execution by constructing an object of class sentry with the noskipws (second) argument false."