No bounds checking for dynamic arrays at compile time?
monarch_dodra
monarchdodra at gmail.com
Thu Dec 13 02:05:22 PST 2012
On Thursday, 13 December 2012 at 09:38:18 UTC, bearophile wrote:
>
> From my usages of a lint tool in C, that's able to perform that
> flow analysis, I have seen that it spots several out of array
> bound mistakes in the code statically.
>
> [SNIP]
>
> Bye,
> bearophile
I guess you still have to keep in mind that in C, out of bounds
access is undefined behavior, and may not error during run-time.
This makes out of bounds access a real bane to find C, and tons
(excessive?) effort have been expanded to avoid it.
In comparison, D will assert on the first out of bounds access,
and you'll immediately see where the problem lies, with no
undefined behavior or whatnot.
While I wouldn't disagree that having the compiler do it
statically would be a good thing, it's not as critically needed
as it would be in C.
I guess I'm just saying the "cost to payback" ratio is not as
high as in C.
More information about the Digitalmars-d
mailing list