public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/34031]  New: money_get:do_get incorrectly sets eofbit for valid input
@ 2007-11-08 18:14 janis at gcc dot gnu dot org
  2007-11-08 18:37 ` [Bug libstdc++/34031] " pcarlini at suse dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: janis at gcc dot gnu dot org @ 2007-11-08 18:14 UTC (permalink / raw)
  To: gcc-bugs

The C++ Standard, in section 22.2.6.1.1, says that if money_get::do_get
recognizes a valid sequence then it does not modify the ios_base::iostate
variable passed to it.  That variable should be set to eofbit only if do_get
has not recognized a valid sequence and no more characters are available.  This
was reported within IBM.

The testcase below gives the following output with GCC 3.3:

Contents of digits = "11"
Contents of retval = " 22"
mystate is goodbit as expected

and the following with later versions, including current mainline:

Contents of digits = "11"
Contents of retval = " 22"
mystate is eofbit, should not have changed

The testcase:

----------------------------------------------------------
#include <locale>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

// Declare our own version of money_get to get access to do_get.
struct MyMoneyGet : public std::money_get<char, char *>
{
  char *
  my_do_get (char *pa, char *pz, bool intl,
             std::ios_base &myios, std::ios_base::iostate &mystate,
             std::string &digits)
  {
    return do_get (pa, pz, intl, myios, mystate, digits);
  }
};

int
main ()
{
  std::string digits;
  MyMoneyGet mg;
  std::ios_base::iostate mystate;
  std::stringstream myios;
  std::locale mylocale (std::locale::classic (), new std::moneypunct<char>);

  myios.imbue (mylocale);
  char s1[] = "11 22";
  char s2[] = "11";             // use this to get the length we want
  char *retval;
  size_t len2 = strlen (s2);

  // Parse the string "11" from the larger string "11 12"; we do that
  // to be able to look at the return value in retval.
  mystate = std::ios_base::goodbit;
  retval = mg.my_do_get (s1, s1 + len2, false, myios, mystate, digits);
  printf ("Contents of digits = \"%s\"\n", digits.c_str ());
  printf ("Contents of retval = \"%s\"\n", retval);
  if (mystate == std::ios_base::goodbit)
    printf ("mystate is goodbit as expected\n");
  else
    {
      if (mystate == std::ios_base::eofbit)
        printf ("mystate is eofbit, should not have changed\n");
      else
        printf ("mystate is %d, should not have changed\n", mystate);
      abort ();
    }
}
-------------------------------------------------------------------

The behavior changed with:

    http://gcc.gnu.org/viewcvs?view=rev&rev=73011

    r73011 | paolo | 2003-10-28 17:09:03 +0000 (Tue, 28 Oct 2003)


-- 
           Summary: money_get:do_get incorrectly sets eofbit for valid input
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janis at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

* [Bug libstdc++/34031] money_get:do_get incorrectly sets eofbit for valid input
  2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
@ 2007-11-08 18:37 ` pcarlini at suse dot de
  2007-11-08 18:52 ` sebor at roguewave dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-11-08 18:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2007-11-08 18:37 -------
Hi Martin. I think this inconsistency between num_get and money_get is just a
special case of our DR 585:

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#585

and that setting eofbit when end of file after successful parsing of a monetary
quantity is consistent with our proposed resolution. Can you confirm? Thanks in
advance.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sebor at roguewave dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

* [Bug libstdc++/34031] money_get:do_get incorrectly sets eofbit for valid input
  2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
  2007-11-08 18:37 ` [Bug libstdc++/34031] " pcarlini at suse dot de
@ 2007-11-08 18:52 ` sebor at roguewave dot com
  2007-11-08 18:59 ` [Bug libstdc++/34031] [DR 585] " pcarlini at suse dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sebor at roguewave dot com @ 2007-11-08 18:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sebor at roguewave dot com  2007-11-08 18:52 -------
Yes, I can confirm that, Paolo. The Apache C++ Standard Library behaves the
same (i.e., the facet sets eofbit).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

* [Bug libstdc++/34031] [DR 585] money_get:do_get incorrectly sets eofbit for valid input
  2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-11-08 18:59 ` [Bug libstdc++/34031] [DR 585] " pcarlini at suse dot de
@ 2007-11-08 18:59 ` pcarlini at suse dot de
  2010-02-08 11:08 ` paolo dot carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-11-08 18:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pcarlini at suse dot de  2007-11-08 18:59 -------
Thanks Martin. Therefore, let's confirm this bug to suspend it immediately
until our DR get resolved.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-08 18:59:04
               date|                            |
            Summary|money_get:do_get incorrectly|[DR 585] money_get:do_get
                   |sets eofbit for valid input |incorrectly sets eofbit for
                   |                            |valid input


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

* [Bug libstdc++/34031] [DR 585] money_get:do_get incorrectly sets eofbit for valid input
  2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
  2007-11-08 18:37 ` [Bug libstdc++/34031] " pcarlini at suse dot de
  2007-11-08 18:52 ` sebor at roguewave dot com
@ 2007-11-08 18:59 ` pcarlini at suse dot de
  2007-11-08 18:59 ` pcarlini at suse dot de
  2010-02-08 11:08 ` paolo dot carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2007-11-08 18:59 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|sebor at roguewave dot com  |
             Status|NEW                         |SUSPENDED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

* [Bug libstdc++/34031] [DR 585] money_get:do_get incorrectly sets eofbit for valid input
  2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-11-08 18:59 ` pcarlini at suse dot de
@ 2010-02-08 11:08 ` paolo dot carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-02-08 11:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2010-02-08 11:08 -------
DR 585 has been resolved to NAD


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |NEW
   Last reconfirmed|2007-11-08 18:59:04         |2010-02-08 11:08:29
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34031


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

end of thread, other threads:[~2010-02-08 11:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 18:14 [Bug libstdc++/34031] New: money_get:do_get incorrectly sets eofbit for valid input janis at gcc dot gnu dot org
2007-11-08 18:37 ` [Bug libstdc++/34031] " pcarlini at suse dot de
2007-11-08 18:52 ` sebor at roguewave dot com
2007-11-08 18:59 ` [Bug libstdc++/34031] [DR 585] " pcarlini at suse dot de
2007-11-08 18:59 ` pcarlini at suse dot de
2010-02-08 11:08 ` paolo dot 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).