What should happen when the assert message expression throws?

kdevel kdevel at vogtner.de
Fri Nov 25 13:03:06 UTC 2022


On Friday, 25 November 2022 at 09:33:21 UTC, Quirin Schroll wrote:

> Another example well-known to many D programmers that is both, 
> best-effort and ideal, is `@safe`. It intends to be a complete 
> (or ideal) solution in the sense that when checking for `@safe` 
> succeeds, the code has no UB (give or take `@trusted`, of 
> course). A compiler that accepts UB in `@safe` code has a bug!

A false positive.

> On the other hand, `@safe` is best-effort in the sense that it 
> does not even intend to cover all non-UB code. There will 
> always be (rather simple) code for which *you* can (rather 
> easily) prove that it is indeed free of UB, but the compiler’s 
> `@safe` checks reject it.

A false negative.

> The language development goes into the direction of recognizing 
> more and more of non-UB code as `@safe` (DIP 1000 most 
> notably), but it will never be able to cover the entirety of 
> non-UB because that would equate to

Make @safe a no-op, then there will be no more false negatives. 
Mission accomplished. I mean: What is the objective of @safe 
anyhow? I stumble already at the first sentence of the manual:

"Safe functions are marked with the @safe attribute."

Is this an imperative or a descriptive sentence?


More information about the Digitalmars-d mailing list