ImportC and nothrow/@nogc?

Walter Bright newshound2 at digitalmars.com
Mon Aug 26 05:53:04 UTC 2024


@trusted means the function has an @safe interface. What the function does 
internally is not checked. For example:

```
@trusted int[] foo()
{
     int* p = cast(int*)malloc(10 * int.sizeof);
     assert(p);
     int[] a = p[0 .. 10];
     return a;
}
```
has a memory safe interface. The following:

```
@trusted int[] foo()
{
     int* p = cast(int*)malloc(10 * int.sizeof);
     assert(p);
     int[] a = p[0 .. 11]; // not memory safe
     return a;
}
```
does not.


More information about the Digitalmars-d mailing list