Re: C++ Bounds Checking



On 2007-06-28 23:54:54 -0300, Gary Scott <garylscott@xxxxxxxxxxxxx> said:

Beliavsky wrote:

On Jun 28, 8:43 pm, Gary Scott <garylsc...@xxxxxxxxxxxxx> wrote:

I probably don't have the syntax correct, but I read recently that you
can force bounds checking on an array by expressing an access something
like:

array.at[i]

whereas:

array[i]

would not cause bounds checking


I wonder if you are thinking of the vector container in the C++
standard library, which can be substituted for the array of C/C++ in
some cases.


Would something like that be useful in Fortran? Seems sort of kludgy
and partially redundant to me.


Good compilers have done checked for some time, and assumed shape
arrays "know their own size", so one can determine the dimensions of
array arguments of procedures. The C++ vector, unlike the C/C++ array,
has a similar feature.

The stated reason for the difference in the article I read was so that programmers could directly control in code whether automatic checking occurred or not.

Excuse my cynicism but it sure sounds like some overly macho hacker wants
his debugging run to completion in 29 seconds instead of 35 seconds and is
willing to waste 3 days effort to achieve that. And it will turn out that
the out of bound subscript occurs somewhere that is not being checked
so another 6 days will be taken to track that down. And he can then brag
about how hard it was to find the bug and squash it.

If the problem occurred where you thought it was it would not be a problem.





.



Relevant Pages

  • Re: Faster way to do this...
    ... > mistake for not expressing my question as well as I should have. ... > array errrrr... ...
    (comp.lang.python)
  • Re: Faster way to do this...
    ... > mistake for not expressing my question as well as I should have. ... > array errrrr... ...
    (comp.lang.python)
  • Re: C++ Bounds Checking
    ... force bounds checking on an array by expressing an access something like: ... So if you handed me an array, ... use the Fortran Programming Language to decide whether the bounds were ...
    (comp.lang.fortran)
  • Re: C++ Bounds Checking
    ... can force bounds checking on an array by expressing an access something ... has a similar feature. ...
    (comp.lang.fortran)
  • Part 4 of Short Steps Toward Generic Programming: KIND Genericity
    ... In this part I will again be discussing a feature that has been ... KIND and select the appropriate instance at compile-time in the ... Assumed Rank Arrays ... argument that don't require knowledge of the rank of the array. ...
    (comp.lang.fortran)