Re: C++ Bounds Checking



dpb wrote:
Wade Ward wrote:
...
How the heck are you supposed to get a compiler to get bounds right when programmers can't? In this source:

...snip code example of using only subset of an array...

, I think I got the right answer by grace. If instead, I had used the intrinsic sum, what would that 85th integer be?

Depends on what you passed SUM() as the argument.
....

Actually, of course, what the uninitialized array entry would be would be immaterial to whether SUM() was or wasn't called, of course... :)

I was going to add that what you're seemingly looking for here is "uninitialized data" usage, not bounds checking.

Most (all?) compilers have compile-time options that can find most instances of uninitialized scalars or character variable references.

Some I believe have options that set all(?) data to unique bit patterns that allows for runtime checking of uninitialized data similar to bounds checking runtime code.

--
.