malloc and calloc should be @trusted because by specification they cannot corrupt memory regardless of what arguments they are passed. core.stdc.stdlib.d has this comment explaining why they aren't @trusted: // We don't mark these @trusted. Given that they return a void*, one has // to do a pointer cast to do anything sensible with the result. Thus, // functions using these already have to be @trusted, allowing them to // call @system stuff anyway. That comment is longer than just writing @trusted twice. Moreover since that comment was written Phobos has adopted the style of wrapping individual statements in @trusted lambdas instead of marking entire functions as @trusted.
@n8sh created dlang/druntime pull request #2901 "Fix Issue 20490 - malloc and free should be `@safe` / `@trusted`" fixing this issue: - Fix Issue 20490 - malloc and free should be `@safe` / `@trusted` There is no good reason not to annotate them correctly. https://github.com/dlang/druntime/pull/2901
Unfortunately, Walter decided against it: https://github.com/dlang/druntime/pull/2901#issuecomment-1086999519