Re: Was this a bug
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Thu, 28 Sep 2006 11:14:10 -0700
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
.
- Follow-Ups:
- Re: Was this a bug
- From: glen herrmannsfeldt
- Re: Was this a bug
- References:
- Was this a bug
- From: David Flower
- Was this a bug
- Prev by Date: Re: comment and IBM xlf
- Next by Date: Re: Was this a bug
- Previous by thread: Was this a bug
- Next by thread: Re: Was this a bug
- Index(es):
Relevant Pages
|