From: "Michael N. Filippov" Newsgroups: gnu.g++.help,gnu.gcc.help,comp.os.msdos.djgpp Subject: ostringstream / not enough memory Date: 31 Oct 2001 11:32:21 GMT Lines: 54 Message-ID: <9rong5$i1m$1@news.itfs.nsk.su> NNTP-Posting-Host: idisys.iae.nsk.su X-Trace: news.itfs.nsk.su 1004527941 18486 193.124.169.11 (31 Oct 2001 11:32:21 GMT) X-Complaints-To: usenet AT news DOT itfs DOT nsk DOT su NNTP-Posting-Date: 31 Oct 2001 11:32:21 GMT User-Agent: tin/pre-1.4-19990517 ("Psychonaut") (UNIX) (Linux/2.4.3 (i586)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello ! Can somebody explain why ostringstream does not throw in this example but just stops growing. Maybe it is my local installation problem (hardly but anyway - I use DJGPP 2.03, GCC 3.02) so if you can recreate not under DOS it would help too. Code is very simple: #include #include using namespace std; int main(void) { char* buffer(0); const size_t buffer_length(1 * 1000 * 1000); try { buffer = new char[buffer_length + 1]; // + 1 for terminating '\0' memset(buffer, 'A', buffer_length); buffer[buffer_length] = 0; // ostringstream oss; string::size_type curr_oss_str_length; string::size_type prev_oss_str_length(0); while (true) { oss << buffer; curr_oss_str_length = oss.str().length(); if (curr_oss_str_length != prev_oss_str_length + buffer_length) { cerr << "appended " << curr_oss_str_length - prev_oss_str_length << " instead of " << buffer_length << endl << "entire length " << curr_oss_str_length << endl; break; } prev_oss_str_length = curr_oss_str_length; } } catch (...) { cerr << "catch (...)" << endl; } delete buffer; return 0; } I see that if there is not enough memory string just stops growing. BTW - same code with my previous configuration (GCC 2.95.2, same ) caused SIGABRT from throw_helper (it couldn't find exception handler I suppose) I would expect that in this example/ code should throw bad_alloc (like if using not ostringstream. but just std::string of std::vector). What is wrong ? Thanks in advance, Michael