[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: About memory allocation failures....
From: Guillaume Laurent <glaurent () telegraph-road ! org>
Date: 2002-03-22 21:51:38
[Download RAW message or body]
On Friday 22 March 2002 22:25, Schmidt, John wrote:
>
> Because you're statment "'new' never returns null, it throws." was wrong,
It's not wrong, it's true for all practical purposes. Here's the deal :
The Standard used to say : new returns 0 on failure. That was amended years
ago (don't know the exact date - before 97 since that was when the standard
was voted). Now new throws bad_alloc by default, but you can set up your own
handler, which indeed may not throw.
So yes, if you really like splitting hairs, "new never returns null" is
wrong. However, setting up your own handler is a fairly advanced technique
which I doubt many compilers support, and even if both conditions are
satisfied, then you still pretty much want your handler to throw anyway
because that's the sanest thing to do. Of course there certainly are
exceptions.
But as far as the audience of this list is concerned, 'new' never returns
null, checking for memory allocation failure is futile except perhaps when
you're allocating a really large buffer, and further inquiries on the subject
should be carried to a suitable place like comp.lang.c++.
--
Guillaume.
http://www.telegraph-road.org
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic