Can precondition failure exit in a recognizable manner?

today, when a Swift program exits due to precondition failure, it prints something like

đź’Ł Program crashed: Illegal instruction at 0x00005d6d19cf4117

this looks a lot like a “corruption” bug (like a misuse of Unmanaged, or one of the known miscompilation modes), so i spent many hours today trying to isolate a suspected refcounting issue instead of realizing this was in fact a precondition failure i had planted myself weeks earlier.

i understand the arguments about printing the error message, which i’ll link here for convenience:

but i feel like it would still be helpful if precondition failures at least indicated they originate from a precondition call, instead of just printing Illegal instruction.

are there reasons why precondition failures can’t identify themselves as precondition failures?

4 Likes