Bad array indexing is considered deadly

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 2 05:12:33 PDT 2017


On 6/2/17 7:55 AM, Arafel wrote:
> But, in the real world if I've got a (web)server that has proper
> isolation, I'd much rather have a server that sends back a 500 [error
> message] for the buggy page and keeps working otherwise, than one that
> is killed and has to be restarted every time a buggy page is asked.

Yes, exactly what I want.

> Perhaps an intermediate solution would be to offer a compiler switch
> that allows Errors to be safely caught (that is, they behave as
> exceptions). As far as I understand from reading this thread, that's
> already the case in debug builds, so it cannot be that bad practice, but
> it would be nice to have a mode that it's otherwise "release", only with
> this feature turned on.

I don't think this is workable, simply because of nothrow. An Error is 
allowed to be thrown in nothrow code, and the compiler can 
simultaneously assume that nothrow functions won't throw. Therefore it 
can legally omit the scaffolding for deallocating scope variables when 
an Exception is thrown (for performance reasons), and leave your program 
in an invalid state.

The only conclusion I can come to is that I need to write my own array 
types. This isn't going to be so bad as I thought, and likely will just 
become second nature to use them.

-Steve


More information about the Digitalmars-d mailing list