www.digitalmars.com         C & C++   DMDScript  

D - bounds checking pointers ?

reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
Walter,
can the gc's method of detecting a pointer to object be used to allow debug
code to detect the array that a pointer is pointing into and so allow
pointer to also be bounds checked (debug only as I assume it will be an
expensive operation) ?
Feb 05 2003
parent "Walter" <walter digitalmars.com> writes:
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message
news:b1s73i$nbr$1 digitaldaemon.com...
 Walter,
 can the gc's method of detecting a pointer to object be used to allow

 code to detect the array that a pointer is pointing into and so allow
 pointer to also be bounds checked (debug only as I assume it will be an
 expensive operation) ?

Potentially, yes, although the gc allocates more memory that is required by the array, so this check would still let slip through invalid pointer offsets.
Feb 13 2003