Raymond Chen's take on so-called zero cost exceptions
deadalnix
deadalnix at gmail.com
Tue Mar 1 01:39:05 UTC 2022
On Monday, 28 February 2022 at 21:39:03 UTC, H. S. Teoh wrote:
> How is this any worse than explicitly checking for error codes?
> Isn't the optimization situation of:
>
> MyObj obj;
> mayThrow();
> ...
> // obj.dtor called
>
> different from:
>
> MyObj obj;
> if (mayError() == ERROR)
> goto END;
> ...
> END:
> // obj.dtor called
>
> ?
>
>
> T
obj can be kept in a register in the goto case, it cannot in the
exception case. So you'll have a couple extra load/store vs extra
branches.
More information about the Digitalmars-d
mailing list