Typical security issues in C++: why the GC isn't your enemy
Dukc
ajieskola at gmail.com
Wed Dec 14 11:45:02 UTC 2022
On Tuesday, 13 December 2022 at 01:50:26 UTC, areYouSureAboutThat
wrote:
>
> and this:
>
> https://doc.rust-lang.org/error_codes/E0133.html
This isn't any different from D.
```D
@system void f() { return; } // This is the unsafe code
@safe void main() {
// error: `@safe` function `D main` cannot call `@system`
function `app.f`
f();
}
@safe void main() {
() @trusted { f(); }(); // ok!
}
```
The difference is that D lets you also write
```D
@trusted void main() {
f(); // ok!
}
```
This is really just a nice shorthand for the `@safe` main with
`@trusted` lambda inside. It's also a better practice, since
`@trusted` in a function signature is easier to spot for a code
reviewer than the lambda inside the function.
More information about the Digitalmars-d
mailing list