From: "Tim Van Holder" Subject: Re: ostringstream / not enough memory Date: Wed, 31 Oct 2001 13:28:39 +0100 Newsgroups: gnu.g++.help,gnu.gcc.help,comp.os.msdos.djgpp Message-ID: References: <9rong5$i1m$1 AT news DOT itfs DOT nsk DOT su> User-Agent: Pan/0.10.0 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-Comment-To: "Michael N. Filippov" X-No-Productlinks: Yes Lines: 26 Organization: -= Skynet Usenet Service =- NNTP-Posting-Host: 194.78.64.238 X-Trace: 1004531470 reader1.news.skynet.be 36459 194.78.64.238 X-Complaints-To: abuse AT skynet DOT be To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > int main(void) > { > char* buffer(0); > const size_t buffer_length(1 * 1000 * 1000); I find it very odd style to use constructor syntax for non-object types. What's wrong with 'const size_t buffer_length = 1 * 1000 * 1000'? > [snip] > delete buffer; should be delete[] > 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). If it does run out of memory, it should probably throw, yes. It would have helped to see the program's output though; you may also want to print the values of oss's badbit and failbit; it might be that all it is required to do by the standard is set failbit on overflow (don't have a copy of the standard handy right now).