public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/51288] New: get_money implementation is missing the sentry object (does not skip leading whitespace)
@ 2011-11-23 20:14 cubbi at cubbi dot org
  2011-11-23 22:52 ` [Bug libstdc++/51288] [C++0x] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: cubbi at cubbi dot org @ 2011-11-23 20:14 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: cubbi@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."


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-28 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 20:14 [Bug libstdc++/51288] New: get_money implementation is missing the sentry object (does not skip leading whitespace) cubbi at cubbi dot org
2011-11-23 22:52 ` [Bug libstdc++/51288] [C++0x] " paolo.carlini at oracle dot com
2011-11-23 23:20 ` paolo.carlini at oracle dot com
2011-11-28 13:46 ` paolo at gcc dot gnu.org
2011-11-28 13:47 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).