runtime hook for Crash on Error
Lars T. Kyllingstad
public at kyllingen.net
Wed Jun 6 02:13:39 PDT 2012
On Friday, 1 June 2012 at 12:29:27 UTC, Steven Schveighoffer
wrote:
> On Fri, 01 Jun 2012 04:48:27 -0400, Dmitry Olshansky
> <dmitry.olsh at gmail.com> wrote:
>
>> I don't agree that OutOfMemory is critical:
>> --> make it an exception ?
>
> No. What we need is a non-throwing version of malloc that
> returns NULL. (throwing version can wrap this). If you want
> to throw an exception, then throw it there (or use enforce).
With some sugar:
auto a = nothrow new Foo; // Returns null on OOM
Then, ordinary new can be disallowed in nothrow code.
IMO, failing assertions and out-of-bounds errors should just
abort(), or, as Sean suggests, call a special handler.
-Lars
More information about the Digitalmars-d
mailing list