delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/03/16:35:17

From: "Ole Laursen" <ole_laursen AT hardworking DOT dk>
Newsgroups: comp.os.msdos.djgpp
References: <3754FA2C DOT 54A26758 AT softhome DOT net>
Subject: Re: new's return on fail
Lines: 24
X-Newsreader: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Message-ID: <7%A53.1490$c4.45382@news030.image.dk>
Date: Thu, 3 Jun 1999 21:47:11 +0200
NNTP-Posting-Host: 212.54.67.86
X-Complaints-To: news-abuse AT image DOT dk
X-Trace: news030.image.dk 928439363 212.54.67.86 (Thu, 03 Jun 1999 21:49:23 MET DST)
NNTP-Posting-Date: Thu, 03 Jun 1999 21:49:23 MET DST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>What does new return if it fails?  I've heard that the standard requires
>that it throw an exception, but also I've heard that it returns NULL
>(like malloc).  I did a test, and it did neither, preferring to exit the
>program.  So, how do I capture this and use it for the greater good
>(rather than just exiting the program)?

Hmm, this is more a C++ question. Have you looked in the C++ FAQ? Maybe
it'll help you (under dynamic storage of something like that):

http://www.cerfnet.com/~mpcline/c++-faq-lite/

Hope that helps, else you might consider trying the comp.lang.c++
newsgroup.

I have never tried using exceptions myself so unfortunately I can't answer
you question directly, but at least I know that 'new' never returns 0...

BTW, are you using an old version of the C++ compiler? If so you'd better
upgrade because I think some of the older versions had problems with
exception.

Ole Laursen


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019