Re: Was this a bug



David Flower <DavJFlower@xxxxxxx> wrote:

I succeeded in generating code that ollks something like this:
MODULE FRED
INTEGER, ALLOCATABLE :: IARRAY(:)
END MODULE
....
USE FRED
CALL SUB ( IARRAY(7) )
....
SUBROUTINE SUB ( I )
USE FRED
(Reallocate IARRAY larger, making lower bound more negative)

Is there anything in the standard making the above code illegal ?

Yes. It is illegal per the standard. Not worth looking up the exact
words, but there is a restriction against a subroutine defining or
undefining something that is an actual argument; you can only do such
definition or undefinition through the corresponding dummy. You mention
that you "reallocate" the array. The first step of such a reallocation
is a deallocation, which undefines the array and thus the actual
argument in question.

That's a kind of bug that is usually not easily detected by compilers.

As to what the various compilers give as symptoms of this particular
error, well, I haven't tried to figure that out. It doesn't seem worth
the bother. I'll just fall back on the "strange things can happen with
illegal code". And when the illegality involves memory allocation, those
symptoms can be strange indeed, and likely vary among compilers.

Some of your symptoms might well be explained by different
implementations of argument passing and optimizations, but I'll not
bother to look more carefully.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: [RFC] Stacking bio support
    ... - If you don't do it (but rely on the fact that the initial allocation is ... Yes, I reallocate. ... rely on (out of tree) bio throttling to prevent the memalloc reserve ...
    (Linux-Kernel)
  • Re: Fastcode Voting - IntToStr Result Length Rule
    ... >2) Use global rule ... the length of the resulting string. ... The discussion is about 'allocation size' if I'm not misunderstanding ... - should it be allowed to not reallocate if the length of the result ...
    (borland.public.delphi.language.basm)
  • Re: Need help with "reallocated sector count"?
    ... Not possible unless I can work out what you are trying to say in that last half, and I still cant. ... That means there are 98 reallocated sectors, ... The drive wont necessarily reallocate on reads ... The allocation pool of spare sectors will be empty, ...
    (comp.sys.ibm.pc.hardware.storage)
  • Re: Rexx Question
    ... and you can't reallocate it while it is in use. ... Using code that extracts the original allocation and includes all ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)