www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Runtime.initialize nothrow?

reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
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?
Oct 15 2017
parent Jacob Carlborg <doob me.com> writes:
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
Oct 16 2017