3 ms·
If I'm @nogc on D, what are the memory safety features I get?
by bsder 4y ago
If I'm @nogc on D, what are the memory safety features I get?
- WalterBright 4y ago1. array bounds checking 2. pointers to the stack cannot escape the lifetime of the stack frame 3. cannot conflate pointers with non-pointers 4. cannot have uninitialized pointers 5. cannot do arithmetic on pointers (must use array slices, which come with array bounds checking) 6. cannot pass the same mutating pointer to a function more than once There are many more of these. They may seem burdensome and restrictive, but actually are not. If you really want to do these things, there is a "system" annotation that can be used.
- bsder 4y agoThanks. I don't know a lot about D and it's nice to get an absolutely definitive answer from the creator himself. :)
- WalterBright 4y agoYou're welcome. I really should write a supplemental page for the documentation that brings all these into one place. Then I can just link to it! Thanks for the inspiration.