------- Comment #3 from David dot Duffy at qimr dot edu dot au  2007-04-14 
01:03 -------
Subject: Re:  Array size declaration depended on order of
 declaration of variable containing size

On Sat, 13 Apr 2007, tobi at gcc dot gnu dot org wrote:

>
>
> ------- Comment #2 from tobi at gcc dot gnu dot org  2007-04-13 15:22 -------
> (In reply to comment #0)
>> GNU Fortran (GCC) 4.3.0 20070412 (experimental)
>> Linux 2.4.20-20030701 #2 SMP
>>
>>   use ped_class
>>   type (ped_data) :: dataset
>>   integer, dimension(dataset%maxsiz) :: nobs
>>
>> works but
>>
>>   use ped_class
>>   integer, dimension(dataset%maxsiz) :: nobs
>>   type (ped_data) :: dataset
>>
>> doesn't.
>
> If I understand you correctly, what you're trying to do is invalid.  You may
> only reference previously declared objects in data object declarations.  In
> your second example dataset is referenced before it is declared.
>
> Please provide a complete testcase, and if the problem is indeed the order of
> declarations please tell us where you think I'm wrong.
>

Hi.

Please find a cutdown example attached.  In this form, it compiles successfully
with gfortran, ifort and g95.  If line 251 is commented out and line 256
uncommented, only g95 compiles it successfully.

Since dataset, nobs and relid are all subroutine arguments, it seems
plausible to me that the order of declaration should be irrelevant, even
though it require more work by the compiler.  I haven't looked at the Fortran
Standard (and probably couldn't work out what it was saying anyway ;)) to see
if there is a defined behaviour.

Cheers,

David Duffy.


------- Comment #4 from David dot Duffy at qimr dot edu dot au  2007-04-14 
01:03 -------
Created an attachment (id=13364)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13364&action=view)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31560

Reply via email to