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]

c++/554: ostrstream sometimes causes program to abort



>Number:         554
>Category:       c++
>Synopsis:       ostrstream sometimes causes program to abort
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 19 18:36:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     charlton@ligo.caltech.edu
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
We have some code that uses
ostrstream to convert a sequence of floating-point numbers to
space-separated text. For very long sequences, ostrstream causes the
program to abort without appearing to throw any exceptions. It seems
to be an out-of-memory error generated when trying to resize the
ostrstream. Should this generate a bad_alloc exception? I haven't
been able to find any way to detect the condition.

Thanks!

Philip
--
Philip Charlton
California Institute of Technology
LIGO Laboratory 18-34
1200 E. California Blvd
Pasadena CA 91125 USA
Phone: +1 (626) 395 8437
Fax:   +1 (626) 793 9744
mailto:charlton@ligo.caltech.edu


gcc --version
2.95.2

uname -a
Linux m90 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686 unknown

#include <strstream>
#include <stdexcept>

using namespace std;

int
main()
{
    unsigned int i = 0;
    ostrstream oss;
    try
    {
 for (;;)
 {
     i++;
     oss << i << "A longish string:";
     if (oss.fail())
     {
  cerr << "Fail!" << endl;
  break;
     }
 }
    }
    catch (exception& e)
    {
 cerr << e.what() << endl;
    }
    catch (...)
    {
 cerr << "other exception" << endl;
    }
    return 0;
}
>How-To-Repeat:

>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]