Re: array-passing trick

On 5/18/2011 2:41 PM, Ken Fairfield wrote:
dpb got most of the points, but missed the following:

On May 18, 10:41 am, Michael Goerz<news...@xxxxxxxxxxxxxxx> wrote:

subroutine print_a(a, n)

integer, intent(in) :: a(1) ! does NOT work with a(2)

The above "a(1)" is an F66-ism, is non-standard and compiler-
dependent. In fact, you're lying to the compiler. A good
checking compiler should complain on the second trip
through the loop, below, when i=2 and you reference a(i)
which is outside the declared bounds of "a".


I was "underneath the impression" (as a walking-malapropism-collection of a former colleague used to say :) ) that there was still a special dispensation for the form for backwards compatibility?

Or has that actually gone away so that it is compiler-dependent? There surely is a lot of code around that uses the construct that would break at runtime if it were enforced (altho runtime checking is something different, recognized).


Relevant Pages

  • Re: array-passing trick
    ... you're lying to the compiler. ... checking compiler should complain on the second trip ...
  • Re: Differences between C and C++
    ... it is really no different than misusing a "void *" pointer. ... one can do it, and the compiler wont complain, but it is the programmers' problem is the behavior is not what was expected, rather than that the compiler didn't give a complaint about it. ... the declaration a prototype and forces the implementation to diagnose ...
  • Re: condition true or false? -> (-1 < sizeof("test"))
    ... In particular, there are no "overflow issues," usual or otherwise. ... Do you really think all those compiler writers simply thought "let's not ... You don't need to know any C, or any language, for it to raise ... How much C does someone need to know, to complain about -1 being silently ...
  • Re: OT: efforts, emo crap...
    ... ok, so possibly, this will be being emo but trying not to be too emo. ... complain about my OTness if you will... ... I can write a compiler, have it all working, but nothing matters. ... When the other implementations are not open source. ...
  • Re: Type of a string literal
    ... Even though the literal will never be evaluated, the compiler ... should not complain about an invalid function argument type. ... This is far from the original question, but where in the standard ... Actually, for some reason I saw fputs not puts, which now makes ...