[swift-users] Parameter Validation

Dmitri Gribenko gribozavr at gmail.com
Mon Dec 7 12:11:51 CST 2015

On Mon, Dec 7, 2015 at 10:02 AM, Jens Alfke <jens at mooseyard.com> wrote:
> On Dec 7, 2015, at 9:40 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> There are
> just two processes -- one is performing a trap, and another one is the
> test harness that verifies that the other process terminated.
> Ah — I thought it was some type of in-process exception/signal handler.

Well, if we used that, then we wouldn't be testing in the same
environment as production code would run in.

Even more, when a compiler sees that the process is going to trap
anyway, it can omit some cleanups, like ARC releases, which will lead
to memory leaks and other surprising behavior.

While it is technically possible to intercept the control flow after a
Swift trap, I would not recommend doing that even for test purposes,
and even less for production code, for the reasons I described.

> What would you like to know?
> Given the above, not much :) I suppose an assertion failure just raises a
> SIGABORT or something similar?

It performs a UD2 instruction on x86, or equivalent on other
platforms.  stdlib/public/core/AssertCommon.swift if you are


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the swift-users mailing list