Hacker News new | past | comments | ask | show | jobs | submit login

Presumably you can add an inlined array access function or macro in the header to do this for you.



If that worked, people would have done it, and C buffer overflows would be a thing of the past.


The reason this hasn't been done is mostly because C programmers have an allergy to runtime checks that might slow their programs by even single digit percentages.


People don't use these other schemes because they are clumsy, inconvenient, look bad, and have never caught on.

With it as part of the syntax, it becomes natural to use them. I'm not making this up, it is based on extensive experience.

The runtime overflow checks can be turned on and off with a compiler switch, so it becomes trivial to see what performance effect it actually has. Critical loops can be coded with ordinary pointers as necessary. For the rest, the performance effect is not measurable.

Again, this is from experience, not supposition.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: