Re: [Lit.] Buffer overruns

From: Bill Unruh (unruh_at_string.physics.ubc.ca)
Date: 01/26/05


Date: 26 Jan 2005 02:33:04 GMT

Mok-Kong Shen <mok-kong.shen@t-online.de> writes:

>infobahn wrote:

>> Mok-Kong Shen wrote:
>>

>>>Since you are at home even with C++ (with its in my humble
>>>view rather rich/wide extent of features/capabilities), that
>>>should be quite simple for you. I am pretty sure you would
>>>then revise your current viewpoint to certain degree.
>>
>>
>> I doubt it. I'm all for bounds-checking; I think it's vital.
>> I just don't think the runtime system should do it unnecessarily.

>That presumably depends on the quality of the compiler.
>A good compiler should be able to optimize (in general quite
>a lot) to save operations that are unnecessary (to certain
>possible extent, of course). I barely have knowledge in
>compiler techniques. But I would think that, if an array A
>is declared with index 1..10 and one has a loop on A[i]
>with i going from 1 to 10 (or a subrange of that), then the
>compiler should be smart enough not to create any code to
>do bound check. As said, if the programmer decides that

Of course then in the midst of the loop you have an
i+=100; A[i]=j;
( of course you meant to write j+=100, but...)

>certain checks are unnecessary (e.g. for reason that any
>potential bound problem in a particular region of the
>program is unessential according to his knowledge) he could
>explicitly instruct the compiler not to do the check in
>that region. (Not every region of a large software is
>safety critical in practice.)

>M. K. Shen



Relevant Pages

  • Re: [EGN] Hoisting Loop Invariants (Was: Re: [EGN] Numerical Accuracy)
    ... compiler out there somewhere that did as you claim. ... > the programmer has this knowledge, then the programmer should not use ... >> string in a loop, regardless of the blatant inefficiency of doing so. ...
    (comp.programming)
  • Re: The Philosophy of Programming?
    ... A compiler is free to ... >>is to allocate on entry to almost any block. ... > int foo{ ... But any programmer who wants to be more than a coder prefers, I think, ...
    (comp.programming)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... what experienced programmers do, ... the compiler doesn't have the free pass to /assume/ that the function ... Nobody has recommended doing all optimization by hand to my knowledge. ... Compiler behavior in optimization simply has no place in a language ...
    (comp.programming)
  • Re: Static/Strong/Implicit Typing
    ... and every programmer would instantly revere the static type analysis. ... will inform your compiler of your construction. ... the two varieties and consciously break the type disjointness. ... Common Lisp is not quite as abstract, ...
    (comp.lang.lisp)
  • Re: Can someone spot the error here?
    ... the compiler can and should assume ... but the programmer is at option to ... a language like Pascal is founded on. ... Wirth was looking both to compiler efficiency, ...
    (comp.lang.pascal.misc)