boundary check on arrays

Why are the compilers(both c & c++) not designed for checking bounds on arrays?

Regs,
progeni..

Comments

  • : Why are the compilers(both c & c++) not designed for checking bounds on arrays?

    It's left out for speed. Use a std::vector (see e.g. www.codepedia.com/1/CppVector) which has optional range checking.

    See ya,
    bilderbikkel

  • : : Why are the compilers(both c & c++) not designed for checking bounds on arrays?
    :
    : It's left out for speed. Use a std::vector (see e.g. www.codepedia.com/1/CppVector) which has optional range checking.
    :
    : See ya,
    : bilderbikkel
    :
    :
    Higher level languages, like languages based on MS .Net Framework (C# and stuff) perform bounds checks. It makes them safer, but also slower.

    But if I remember correctly, MS Visual Studio 6 offers an project-based option to include bounds checks in the compiled code.

    Greets,
    Eric Goldstein
    www.gvh-maatwerk.nl

  • : But if I remember correctly, MS Visual Studio 6 offers an project-based option to include bounds checks in the compiled code.

    You could an optional bound check using this code:

    [code]
    #ifndef NDEBUG
    myVector.at(index) = something();
    #else
    myVector[index] = something();
    #endif
    [/code]

    See ya,
    bilderbikkel

  • : : But if I remember correctly, MS Visual Studio 6 offers an project-based option to include bounds checks in the compiled code.
    :
    : You could an optional bound check using this code:
    :
    : [code]
    : #ifndef NDEBUG
    : myVector.at(index) = something();
    : #else
    : myVector[index] = something();
    : #endif
    : [/code]
    :
    : See ya,
    : bilderbikkel
    :
    [blue]Good idea, but it is better to generalize this macro:
    [/blue]
    : [code]
    : #ifndef NDEBUG
    : #define SET_ARR_CELL(arr,idx,val) arr.at(idx) = val
    : #else
    : #define SET_ARR_CELL(arr,idx,val) arr[idx] = val
    : #endif

    ...

    SET_ARR_CELL (MyVector, index, something ());
    : [/code]
    :

  • : : Why are the compilers(both c & c++) not designed for checking bounds on arrays?
    :
    : It's left out for speed. Use a std::vector (see e.g. www.codepedia.com/1/CppVector) which has optional range checking.
    :
    : See ya,
    : bilderbikkel
    :
    : Thanks bilder..meet u later with some more stuff
    Regs,
    Progeni

  • : : : Why are the compilers(both c & c++) not designed for checking bounds on arrays?
    : :
    : : It's left out for speed. Use a std::vector (see e.g. www.codepedia.com/1/CppVector) which has optional range checking.
    : :
    : : See ya,
    : : bilderbikkel
    : :
    : :
    : Higher level languages, like languages based on MS .Net Framework (C# and stuff) perform bounds checks. It makes them safer, but also slower.
    :
    : But if I remember correctly, MS Visual Studio 6 offers an project-based option to include bounds checks in the compiled code.
    :
    : Greets,
    : Eric Goldstein
    : www.gvh-maatwerk.nl
    :
    : thank u,EG..
    Regs,
    Progeni

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories