Re: C++ Bounds Checking
- From: dpb <none@xxxxxxx>
- Date: Fri, 29 Jun 2007 15:51:00 -0500
Wade Ward wrote:
....
So bounds checking is going to issue a diagnostic if I want to assign to say array(-1) or array(90) given that I have an 85-dimensional entity. Indeed, I tried to use the intrinsic sum but got a buffer overflow at runtime. I try to familiarize myself with the intrinsics as I go. It just seems like a tall order to ask a compiler to know what's going to happen at runtime.
a) Yes
b) A "buffer" overflow sounds strange for the error message in your case -- numeric overflow perhaps as the array wasn't initialized and there's no telling what the memory contents of the uninitialized array cell were. But assuming SUM(age) was what you requested, the size of the array itself was well specified and in bounds. If, of course, you tried something else, all bets are off... :)
c) It is--the compiler itself doesn't actually do it (in most cases it is indeed impossible), it simply (if requested) generates the extra code to be executed at runtime to perform the checking.
See my followup note on uninitialized variables and array elements checking...
--
.
- References:
- C++ Bounds Checking
- From: Gary Scott
- Re: C++ Bounds Checking
- From: Gary Scott
- Re: C++ Bounds Checking
- From: Wade Ward
- Re: C++ Bounds Checking
- From: dpb
- Re: C++ Bounds Checking
- From: Wade Ward
- C++ Bounds Checking
- Prev by Date: Re: Form k = i + j and test for overflow.
- Next by Date: Re: Please help me understand my code
- Previous by thread: Re: C++ Bounds Checking
- Next by thread: Re: C++ Bounds Checking
- Index(es):
Relevant Pages
|