public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/44441]  New: std::getline set failbit in situation when shouldn't
@ 2010-06-07 11:07 qwak82 at gmail dot com
  2010-06-07 11:20 ` [Bug libstdc++/44441] " schwab at linux-m68k dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: qwak82 at gmail dot com @ 2010-06-07 11:07 UTC (permalink / raw)
  To: gcc-bugs

In this code s failbit is set if last line in s is empty (stream ends with
\n\n):
std::istream s;
//s is some kind of input stream like std::istringstream s("\n\n");
while (s.good()) {
 std::string line;
 std::getline(s, line);
}


-- 
           Summary: std::getline set failbit in situation when shouldn't
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qwak82 at gmail dot com
  GCC host triplet: ubuntu linux x86-64


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


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

* [Bug libstdc++/44441] std::getline set failbit in situation when shouldn't
  2010-06-07 11:07 [Bug libstdc++/44441] New: std::getline set failbit in situation when shouldn't qwak82 at gmail dot com
@ 2010-06-07 11:20 ` schwab at linux-m68k dot org
  2010-06-07 11:36 ` qwak82 at gmail dot com
  2010-06-07 11:56 ` redi at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: schwab at linux-m68k dot org @ 2010-06-07 11:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at linux-m68k dot org  2010-06-07 11:19 -------
You are getting eof.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/44441] std::getline set failbit in situation when shouldn't
  2010-06-07 11:07 [Bug libstdc++/44441] New: std::getline set failbit in situation when shouldn't qwak82 at gmail dot com
  2010-06-07 11:20 ` [Bug libstdc++/44441] " schwab at linux-m68k dot org
@ 2010-06-07 11:36 ` qwak82 at gmail dot com
  2010-06-07 11:56 ` redi at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: qwak82 at gmail dot com @ 2010-06-07 11:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from qwak82 at gmail dot com  2010-06-07 11:36 -------
But also fail bit, this program prints:
line: a          //this is OK, first line
line:            //this is also OK, second (empty) line
fail bit         //eof is set - OK; but fail bit should be set here?

#include <iostream>
#include <sstream>

int main() {
std::istringstream s("a\n");
while (s.good()) {
 std::string line;
 std::getline(s, line);
 std::cout << "line: " << line << std::endl;
}
if (s.fail()) std::cout << "fail bit";
return 0;
}


-- 


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


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

* [Bug libstdc++/44441] std::getline set failbit in situation when shouldn't
  2010-06-07 11:07 [Bug libstdc++/44441] New: std::getline set failbit in situation when shouldn't qwak82 at gmail dot com
  2010-06-07 11:20 ` [Bug libstdc++/44441] " schwab at linux-m68k dot org
  2010-06-07 11:36 ` qwak82 at gmail dot com
@ 2010-06-07 11:56 ` redi at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-06-07 11:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from redi at gcc dot gnu dot org  2010-06-07 11:56 -------
[lib.string.io] paragraph 8
If the function extracts no characters, it calls is.setstate(ios_base::failbit)
which may throw ios_base::failure (27.4.4.3).


-- 


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


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

end of thread, other threads:[~2010-06-07 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-07 11:07 [Bug libstdc++/44441] New: std::getline set failbit in situation when shouldn't qwak82 at gmail dot com
2010-06-07 11:20 ` [Bug libstdc++/44441] " schwab at linux-m68k dot org
2010-06-07 11:36 ` qwak82 at gmail dot com
2010-06-07 11:56 ` redi at gcc dot gnu dot org

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).