nothrow and Throwable?

Manu turkeyman at gmail.com
Mon Apr 7 03:46:08 UTC 2025


So, I've never used an exception before, but I guess there's a first time
for everything :P

It seems to be that `Throwable` transcends `nothrow`...
Other than proving code correct-ness, the point of `nothrow` as I see it,
is to inform the compiler that it doesn't have to synthesise unwind tables
for everything in no-throw land... but since Throwable can pass through
`nothrow` territory, how are any RAII objects cleaned up while it unwinds?

void code() nothrow
{
  RAII something;

  doesntThrow();

  // destroy something
}

void  doesntThrow() nothrow
{
  try
     canThrow();
  catch (Exception)
  {
    // catch exceptions from canThrow
  }
}

void canThrow()
{
  throw new Throwable();
}


I expect that an unwind table should not be generated for code(), and so
`RAII something` should not be tidied up if `doesntThrow` actually does
throw... is that what's going on here?

I guess the idea is that Throwable is intended to never be caught, and so
we don't really care about tidying up since an abort is imminent?
Am I reading this correctly... or is it actually that unwind tables are
just always generated for everything, even `nothrow` things?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20250407/4b2e85fe/attachment.htm>


More information about the Digitalmars-d mailing list