Runtime.initialize nothrow?

Jacob Carlborg doob at me.com
Mon Oct 16 09:08:16 UTC 2017


On 2017-10-15 16:19, Luís Marques wrote:
> The initialize and terminate methods of core.runtime.Runtime aren't 
> nothrow. Can initialize actually throw? If so, is it safe to catch the 
> Throwable and use it, given that the RT isn't properly initialized? If 
> it doesn't actually throw, shouldn't it be marked nothrow?

It can throw. If an exception is thrown during the initialization of the 
runtime it will be caught (this includes exceptions thrown in module 
constructors and similar). But when the runtime prints the caught 
exception it can throw again, because eventually it will call "toString" 
on the caught exception which can throw.

Adding an additional "catch" around the call to "toString" would solve that.

The rest of the functions that are called during the initialization of 
the runtime are just missing the "nothrow" annotation.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list