3 ms·
But they key safety feature is bounds checking, not just preventing the decay to pointer.
by blub 8y ago
But they key safety feature is bounds checking, not just preventing the decay to pointer.
- WalterBright 8y agoOnce you have the array length and pointer, the compiler (as the D compiler does) inserts the array bounds check.
- blub 8y agoIndeed, however if you will try to convince a group of C programmers that arrays shouldn't decay to pointers you will get a different reaction compared to trying to convince them that all array accesses should be bounds checked. I would lead with the stronger demand, because that's what would IMO trigger the more interesting discussion.
- WalterBright 8y agoI've presented the idea in my article to a room of C programmers a couple times, and the reaction I get is just a blank look. No discussion. I'm a bit baffled.
- baybal2 8y agoHi Walter! Surprised to see you here! As a former C dev (ran away to webdev years ago from embedded due to flaccid job market) I'm open to an idea of on-demand boundary checks. To me it will just be a matter of having the compiler insert them for me or me writing them myself.