delorie.com/archives/browse.cgi | search |
From: | "Tim Van Holder" <notme AT spamproofemail DOT com> |
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: | <pan.2001.10.31.13.28.35.881.26631@spamproofemail.com> |
References: | <9rong5$i1m$1 AT news DOT itfs DOT nsk DOT su> |
User-Agent: | Pan/0.10.0 (Unix) |
Mime-Version: | 1.0 |
X-Comment-To: | "Michael N. Filippov" <michael AT idisys DOT iae DOT nsk DOT su> |
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 <sstream>) > 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).
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |