Re: another day, another patch ...

JF Mezei wrote:
re: bounds checking.

In a static array definition, I would define an array of say 100 items which would be the maximum I would ever expect to get.

So a "fancy" compiler would check array bounds within the first 100 items.

However, if my program has only loaded 27 items into the array, the compiler won't know this and will not prevent my program from accessing item 28.

So I still need logic in my program to ensure I don't access uninitialised areas or an array.

That is a C concept as well.

Many other languages would have that initialized.

And in a dynamically allocated array that may grow dynamically (realloc), you also need to have code to detect when your array is full so that you can add another chunk of memory to progressively grow it. (consider receiving an HTML page whose size is unknown, it should be short, or it could be very very long).

C makes this easy. COBOL isn't very good for that.

C is lousy at compared with languages that has a string type.


Relevant Pages

  • Re: Idea for ECMA/C# Standard - compile time hash for performance
    ... I agree with you the chance of a compiler change is slim, ... and then delegating to the standard hash for fields accessed less frequently. ... or the array lookup which would require the ... > 64-bit architecture) for each enum value that doesn't map to anything. ...
  • Re: Q: Checking the size of a non-allocated array?
    ... an actual argument is already invalid ... First note that you don't have an unallocated array in the subroutine. ... it is comparable to disassociated or undefined pointers. ... Obviously the compiler has ...
  • Re: Windows array allocation problem
    ... array reference has to have a 64-bit index or array subscript triplet? ... to fit in one. ... That assumes, of course, that your compiler ... limits on just about anything. ...
  • Re: Is this expected behavior or not
    ... This gives you array interfaces while keeping arrays ... to know the representation in order to be able to pass it meaningfully. ... not a normal array if you are using the character interface). ... should have a tag and it's up to the compiler how to implement it. ...
  • Bounds checked arrays
    ... As everybody knows, the C language lacks ... When the state of this toggle is ON, the compiler ... Important is to know that the array updates ... We have just to allow him/her to specify what to do ...