Re: C++ Bounds Checking



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...

--

.



Relevant Pages

  • Re: VBscript Bufferoverflow, code - tools
    ... That statement should never overflow. ... which is a variant array. ... I think the buffer overflow was in this line; ... Dim tmp ...
    (microsoft.public.scripting.vbscript)
  • RE: Re[2]: Stack Overflow
    ... The NX bits at the hardware level work by marking certain regions of memory ... I agree with what you said about programming languages. ... an array in one of such languages. ... If anything, while memory management itself falls to the OS, overflow ...
    (Security-Basics)
  • RE: Re[2]: Stack Overflow
    ... an array in one of such languages. ... better because of the idea that you do not have to keep track of memory so ... If anything, while memory management itself falls to the OS, overflow ... trying to find any one of the insecurities in java applications that exist ...
    (Security-Basics)
  • Re: Needed info on Buffer/Boundary Overflow Attacks
    ... Needed info on Buffer/Boundary Overflow Attacks ... A vulnerability is characterized as an "Input validation error" if the ... While it could be argued that buffer overflow ...
    (Security-Basics)
  • Re: Buffer overflows and asctime()
    ... Mr Kuyper the subject of this thread is asctime() and what I say ... 999 just to avoid buffer overflow issues that are not relevant to the ... The standard does not say this, ... a reference implementation containing a buffer overflow. ...
    (comp.std.c)