public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/37958]  New: num_get<>::do_get(bool) sets eofbit flag incorrectly when boolalpha == true
@ 2008-10-30 15:01 tsyvarev at ispras dot ru
  2008-10-30 16:09 ` [Bug libstdc++/37958] " paolo dot carlini at oracle dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: tsyvarev at ispras dot ru @ 2008-10-30 15:01 UTC (permalink / raw)
  To: gcc-bugs

There are some examples in the description of member function of the num_get<>
facet

iter_type do_get(iter_type in, iter_type end, ios_base& str, ios_base::iostate&
err, bool& val) const

for the case when (str.flags() & ios_base::boolalpha) != 0, that clarify the
algorithm that the function implements (22.2.2.1.2, p16):

For targets true: "1" and false: "0", the input sequence "1" yields val == true
and err == str.goodbit. For empty targets (""), any input sequence yields err
==
str.failbit.

But in both cases implementation also sets flag str.eofbit in err.

It seems that implementation always set str.eofbit when after call of the
function (in == end).

But standard states(22.2.2.1.2, p16) that this flag should be set only when:
"if, when seeking another character to match, it is found that (in == end)" (on
success)
or "if the reason for the failure was that (in == end)" (on fail)

This conditions are not the same as simply (in == end).

Short test reproduce this difference for targets "true" and "false" and input
sequence "true" (similar to the first example):

test.cpp:

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

int main()
{
    istringstream is("true");
    bool result;
    is >> boolalpha >> result;

    if(is.rdstate() & ios_base::eofbit)
        cout << "eofbit was set." << endl;
    else
        cout << "eofbit wasn't set." << endl;
    return 0;
}

andrew@Ubuntu:/mnt/hgfs/shared/temp/test$ g++ test.cpp && ./a.out
eofbit was set.
andrew@Ubuntu:/mnt/hgfs/shared/temp/test$ g++ --version
g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The detailed bug description can be found at: 

http://linuxtesting.org/results/report?num=S0735


-- 
           Summary: num_get<>::do_get(bool) sets eofbit flag incorrectly
                    when boolalpha == true
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tsyvarev at ispras dot ru


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


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

end of thread, other threads:[~2008-11-06 11:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-30 15:01 [Bug libstdc++/37958] New: num_get<>::do_get(bool) sets eofbit flag incorrectly when boolalpha == true tsyvarev at ispras dot ru
2008-10-30 16:09 ` [Bug libstdc++/37958] " paolo dot carlini at oracle dot com
2008-10-30 16:17 ` paolo dot carlini at oracle dot com
2008-10-30 16:53 ` paolo dot carlini at oracle dot com
2008-10-31 10:36 ` tsyvarev at ispras dot ru
2008-10-31 10:37 ` paolo dot carlini at oracle dot com
2008-10-31 10:49 ` tsyvarev at ispras dot ru
2008-10-31 16:50 ` paolo at gcc dot gnu dot org
2008-10-31 16:51 ` paolo dot carlini at oracle dot com
2008-11-01 12:22 ` tsyvarev at ispras dot ru
2008-11-01 12:37 ` paolo dot carlini at oracle dot com
2008-11-01 15:53 ` tsyvarev at ispras dot ru
2008-11-01 16:03 ` tsyvarev at ispras dot ru
2008-11-01 16:20 ` paolo at gcc dot gnu dot org
2008-11-01 16:23 ` paolo dot carlini at oracle dot com
2008-11-01 18:44 ` tsyvarev at ispras dot ru
2008-11-01 18:49 ` paolo dot carlini at oracle dot com
2008-11-01 19:06 ` paolo dot carlini at oracle dot com
2008-11-01 22:12 ` paolo at gcc dot gnu dot org
2008-11-06  7:17 ` tsyvarev at ispras dot ru
2008-11-06 11:54 ` 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).