Hacker News new | ask | show | jobs
by WalterBright 935 days ago
The D language dynamic array, which is a pointer+length pair, has (over time) nearly completely supplanted pointer arithmetic. The pair prevents buffer overflows and underflows.

Raw pointer arithmetic is not allowed in code marked @safe.

I've proposed it for C and C++:

https://www.digitalmars.com/articles/C-biggest-mistake.html

It would be simple to add it, and would be legacy compatible.