-
-
Notifications
You must be signed in to change notification settings - Fork 411
Replace in with const scope in core.stdc
#2680
Conversation
|
Thanks for your pull request and interest in making D better, @JinShil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2680" |
But none of those function leak the pointers given, which is the whole point of scope. |
Hopefully they don't, but C has no way to express such a thing and no way to statically enforce it, so why would we assume that that's the case unless we were to manually audit the C code? |
The C standard. (From memory the only function that is obviously not
Because this isn't some random C library downloaded from some dark and dodgy corner of the internet, this is the C standard library we're talking about. Its only dependance in on the hardware and the OS system calls. If its buggy, malicious, swapped out with LD_PRELOAD, then a) there is nothing we can do to protect against that, and b) you have much more pressing concerns, namely that your C standard lib is dud. This is a pragmatism vs purism issue, and I'm firmly for the pragmatism. The threat model of having a malfunctioning C standard library is not one we should be concerning ourselves with. |
in with const in core.stdcin with const scope in core.stdc
|
Updated to use |
About This PR
Followup to #2676 and dlang/phobos#7110
This is the first of several PRs I intend to submit, breaking up #2677 into multiple PRs.
This PR only addresses C language bindings in
core.stdc. Since C does not have any concept of scoped pointers, I think it is arguably a mistake for these to bein.Background
This PR is in support of dlang/dmd#10179
inas a parameter storage class is defined asscope const. Howeverinhas not yetbeen properly implemented so its current implementation is equivalent to
const. Properlyimplementing
innow will likely break code, so it is recommended to avoid usingin, andexplicitly use
constorscope constinstead, untilinis properly implemented.The use of
inas a parameter storage class is already discouraged in the documentation. See https://dlang.org/spec/function.html#parameters