public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled
@ 2012-07-16 16:11 gccbz.10.petechap at spamgourmet dot com
  2012-07-16 17:00 ` [Bug libstdc++/53984] " gccbz.10.petechap at spamgourmet dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gccbz.10.petechap at spamgourmet dot com @ 2012-07-16 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53984
           Summary: iostream operation throwing exception when exceptions
                    not enabled
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gccbz.10.petechap@spamgourmet.com


I'm getting an exception thrown in a situation where I believe a failbit should
be set instead.
Is my expectation wrong?

-------------------
#include <fstream>
#include <sstream>

int main()
{
    std::ifstream in(".");
    std::ostringstream out;
    if (in)
      in >> out.rdbuf();
}
-------------------


terminate called after throwing an instance of 'std::ios_base::failure'
  what():  basic_filebuf::underflow error reading the file
Aborted (core dumped)


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

* [Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
  2012-07-16 16:11 [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled gccbz.10.petechap at spamgourmet dot com
@ 2012-07-16 17:00 ` gccbz.10.petechap at spamgourmet dot com
  2012-07-16 17:26 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gccbz.10.petechap at spamgourmet dot com @ 2012-07-16 17:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Pete Chapman <gccbz.10.petechap at spamgourmet dot com> 2012-07-16 17:00:10 UTC ---
Even simpler:

-------------------
#include <fstream>
int main()
{
        std::ifstream in(".");
        int x;
        if (in)
          in >> x;
}
-------------------


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

* [Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
  2012-07-16 16:11 [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled gccbz.10.petechap at spamgourmet dot com
  2012-07-16 17:00 ` [Bug libstdc++/53984] " gccbz.10.petechap at spamgourmet dot com
@ 2012-07-16 17:26 ` redi at gcc dot gnu.org
  2013-12-04 16:05 ` tom at kera dot name
  2014-05-20 22:45 ` igorlord at alum dot mit.edu
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-16 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-07-16
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-16 17:26:39 UTC ---
Confirmed, I'm not sure filebuf::underflow should throw on invalid byte
sequences either.


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

* [Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
  2012-07-16 16:11 [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled gccbz.10.petechap at spamgourmet dot com
  2012-07-16 17:00 ` [Bug libstdc++/53984] " gccbz.10.petechap at spamgourmet dot com
  2012-07-16 17:26 ` redi at gcc dot gnu.org
@ 2013-12-04 16:05 ` tom at kera dot name
  2014-05-20 22:45 ` igorlord at alum dot mit.edu
  3 siblings, 0 replies; 5+ messages in thread
From: tom at kera dot name @ 2013-12-04 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

Tomalak Geret'kal <tom at kera dot name> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tom at kera dot name

--- Comment #3 from Tomalak Geret'kal <tom at kera dot name> ---
Another testcase was proposed under the following Stack Overflow question:

  http://stackoverflow.com/q/20371956/560648

The answer to that question was a link to this bug.


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

* [Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
  2012-07-16 16:11 [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled gccbz.10.petechap at spamgourmet dot com
                   ` (2 preceding siblings ...)
  2013-12-04 16:05 ` tom at kera dot name
@ 2014-05-20 22:45 ` igorlord at alum dot mit.edu
  3 siblings, 0 replies; 5+ messages in thread
From: igorlord at alum dot mit.edu @ 2014-05-20 22:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984

--- Comment #4 from Igor <igorlord at alum dot mit.edu> ---
This is a really evil bug.  I wonder why the Importance is not higher.

This may crash programs that try to read many /proc files on Linux.


~$ g++ -x c++ -o test - <<EOF
#include <fstream>
#include <unistd.h>
int main(int argc, char *argv[])
{
    std::ifstream in(argv[1]);
    sleep(4);
    std::string s;
    if (in)
      in >> s;
    return 0;
}
EOF

~$ sleep 2 & ./test "/proc/${!}/stat"

terminate called after throwing an instance of 'std::ios_base::failure'
  what():  basic_filebuf::underflow error reading the file
Aborted (core dumped)


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

end of thread, other threads:[~2014-05-20 22:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16 16:11 [Bug libstdc++/53984] New: iostream operation throwing exception when exceptions not enabled gccbz.10.petechap at spamgourmet dot com
2012-07-16 17:00 ` [Bug libstdc++/53984] " gccbz.10.petechap at spamgourmet dot com
2012-07-16 17:26 ` redi at gcc dot gnu.org
2013-12-04 16:05 ` tom at kera dot name
2014-05-20 22:45 ` igorlord at alum dot mit.edu

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