Re: range checking



Christian Christmann wrote:
Hi,

in GDB you can set the option "check range". However,
this option just works with some languages that
have to be defined in GDB by "set language ...".

When choosing C, C++ or Java as langauge, the
range-checking option is not available, but it works
with e.g. Pascal. What exactly is meant by the
term "range checking"? Does Pascal allow to check if
for example arrays are accessed out of their range, like

int[2] = {1, 2};
int{2] = 5; // int[2] out of range

Yes.
Generally this feature isn't normally available in C even as a compiler
switch. It was once available as a patch to GCC, but irritatingly was
never installed. The TCC does it though.

In C it is difficult to do in general, because the language supports
arbitrary operations on pointers. It can only be done by making
assumptions about pointers that come from other libraries.

In C implementations other than TCC you can still do something though,
you can range check check heap allocated arrays. To do this you need a
memory debugger library such as "Electric Fence".

.



Relevant Pages

  • Re: Operator overloading in C
    ... All development of C as an independent language has ... making any changes or improvements to the standard ... The lack of a counted string data structure, ... Pointers can't be used for arg1 or arg2. ...
    (comp.std.c)
  • Re: pointers?
    ... There's absolutely nothing abstract in pointers. ... Take the C array: if you write ... To the assembly language programmers who were the first generation adopters of C, this mental mapping was very tight. ... Forth gained the most traction on machines like the IBM 1130 and the Data General Nova. ...
    (comp.lang.forth)
  • Re: Modifying Class Object
    ... Python as a language is implemented in many languages. ... therefore has no pointers or references, ... On top of the multiple fallacies, dubious snipping of arguments, ...
    (comp.lang.python)
  • Re: About programing, a general question
    ... The thing to keep in mind here is what is the purpose of the language ... Keep in mind that many first year programming / computing science ... Typing of variables ... I see a lot of complaints about pointers in all these messages, ...
    (Fedora)
  • Re: About programing, a general question
    ... The thing to keep in mind here is what is the purpose of the language ... Keep in mind that many first year programming / computing science ... Typing of variables ... I see a lot of complaints about pointers in all these messages, ...
    (Fedora)