3 ms·
>runtime bounds check The reason people use c, is to get higher speed by avoiding those kinds of checks. A real solution most avoid slowdowns.
by im3w1l 13y ago
>runtime bounds check
The reason people use c, is to get higher speed by avoiding those kinds of checks. A real solution most avoid slowdowns.
- marshray 13y agoYou can encode the length of an array in the type in C++, at compile time.
- pjmlp 13y agoIf the reason was to avoid those checks, then people really don't know better. Turbo Pascal => {$R-} Ada => pragma Suppress (Index_Check); Modula-3 => cm3 -A D => dmd -fnoboundscheck / array.ptr[index] in @system code Just a few examples. Additionally there are lots of research how to remove bounds checking in compiler optimizations http://citeseer.uark.edu:8080/citeseerx/showciting;jsessionid=749D9B8FE7B1755974DA5561D1926781?cid=71083&sort=cite&start=10 http://citeseer.uark.edu:8080/citeseerx/showciting;jsessioni... What C has going for it is the symbiotic relationship with UNIX, 40 years of optimizations in most compilers and the historical baggage of being around for so long. Other better languages suffered from having been shown the door as UNIX spread into the enterprise, but there was a time when C compilers didn't generate better code as the other ones.