This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/9561: ostream inserters rethrow exception of wrong type


>Number:         9561
>Category:       libstdc++
>Synopsis:       ostream inserters rethrow exception of wrong type
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 04 01:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     sebor@roguewave.com
>Release:        3.2.1
>Organization:
>Environment:

>Description:
The program below is expected to exit with the status of 0 but when compiled with gcc/libstdc++ 3.2.1 it exits with 2, indicating that the inserter throws an exception of the wrong type instead of the one thrown from overflow.

Regards
Martin
>How-To-Repeat:
#include <ostream>
#include <streambuf>

struct foobar: std::exception { };

struct buf: std::streambuf
{
    virtual int_type overflow (int_type) {
        throw foobar ();
        return -1;
    }
};

int main ()
{
    buf b;

    std::ostream strm (&b);

    strm.exceptions (std::ios::badbit);

    try {
        strm << std::endl;
    }
    catch (foobar) {
        return !(strm.bad ());
    }
    catch (...) {
        return 2;
    }

    return 3;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]