@trusted attribute should be replaced with @trusted blocks

Ogi ogion.art at gmail.com
Thu Jan 16 10:46:07 UTC 2020


On Wednesday, 15 January 2020 at 16:54:58 UTC, Joseph Rushton 
Wakeling wrote:
> So here's the problem with this approach (which was mentioned 
> by several people in the discussion): the actual safety of a 
> function like this is usually down to the combination of the 
> lines that (in your example) are both inside and outside the 
> @trusted block.

The are two scenarios of memory corruption in a function with a 
@trusted block. Either @trusted section is incorrect, or the 
@trusted section is given incorrect input. Safe code that has no 
deal with @trusted code cannot compromise safety.

So while the culprit can be outside of @trusted block, it will 
lower the number of suspects. It will give you a good idea of the 
required safety checks.


More information about the Digitalmars-d mailing list