Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Compiler Question

Author: David Hanley

Date: 17:23:25 01/18/02

Go up one level in this thread



The simple answer is that something like that is hard/impossible to do in C.  An
array is simply a pointer to some memory.  There's no really *good* way to tell
how large that chunk of memory is.  If the C compiler is using certian kind of
heap structures you could determine the size of the chunk of memory from the
heap structure.  BUT even if you could do that, if you incremented the pointer
so that it was inside another chunk of memory, it would look at the size of
*that* chunk, and the bounds check would be OK.

The the pascal you used, arrays were really arrays, and carried around a size
tag with them.

You can do some sorts of bounds checking in C with some tools, but it *CANNOT*
catch everything or even many cases.

I was using STL recently and i was surperised that vectors don't have bounds
checking.  I would think it would be in there as a switch, at least.

dave



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.