Functions, nothrow and assert
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 8 04:45:32 PDT 2016
On Thursday, 8 September 2016 at 11:40:17 UTC, Russel Winder
wrote:
> Is the fact that:
>
> void f() nothrow {
> assert(1 == 0);
> }
>
> int main() {
> f();
> return 0;
> }
>
> compiles fine but at run time f does indeed throw an exception
> what should happen? If it is what does nothrow actually mean?
f() is nothrow because assert() throws an "AssertError" not an
"Exception". Since Error descendants are not recoverable the
program usually crashes.
More information about the Digitalmars-d-learn
mailing list