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.

Arne
.



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. ...
    (microsoft.public.dotnet.languages.csharp)
  • 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 ...
    (comp.lang.fortran)
  • 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. ...
    (comp.lang.fortran)
  • 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. ...
    (comp.lang.ada)
  • Re: Error handling library
    ... which lets the compiler catch out-of-range usage. ... and assuming that a higher int means "more dangerous error" ... with a comment warning that one is used as an index into the array ... languages while running (an array of languages, ...
    (comp.lang.c)