The following four variants of declarations have been tried in a block 
 data statement with gfortran 4.1.3 and partly also with 4.3.0: 
 Var. 1: 
 character(len=3) :: emname(nmin)=(/'bar','baz'/) 
 common/nmstr/emname 
 gives this error: 
  In file test.f90:16 
 common/nmstr/emname 
                   1 
 Error: Previously initialized symbol 'emname' in COMMON block 'nmstr' 
 at (1) 

Var. 2: 
 common/nmstr/emname 
 character(len=3) :: emname(nmin)=(/'bar','baz'/) 
 gives this error: 
  In file test.f90:19 
 character(len=3) :: emname(nmin)=(/'bar','baz'/) 
                                                1 
 Error: Initializer not allowed for COMMON variable 'emname' at (1) 
  In file test.f90:16 
 common/nmstr/emname 
                   1 
 Error: Symbol 'emname' at (1) has no IMPLICIT type 

Var. 3: 
 common/nmstr/emname 
 data emname/'bar','baz'/ 
 character(len=3) :: emname(nmin) 

gives this error: 
 test.f90:1: internal compiler error: in check_data_variable, at 
 fortran/resolve.c:5865 
 Please submit a full bug report, 
 with preprocessed source if appropriate. 

Var. 4: 
 character(len=3) :: emname(nmin) !=(/'bar','baz'/) 
 common/nmstr/emname 
 data emname/'bar','baz'/ 

works. 
My question is this: I thought all four variants are compliant with the
standard. Which ones are possibly not, and where does gfortran indeed have a
bug? Var. 1 worked with the Intel compiler; I didn't/can't test the others. The
complete test program is below (comment/uncomment some lines as applicable). My
system is SUSE Linux 10.2.

program foo 
 implicit none 
 integer, parameter :: nmin=2 
 double precision :: rho0(nmin) 
 common/phasedat/rho0 

end program foo 

block data thdinit 
 implicit none 
 integer, parameter :: nmin=2 
 !double precision :: rho0(nmin) 
 common/phasedat/rho0 
 double precision :: rho0(nmin) 
 character(len=3) :: emname(nmin) !=(/'bar','baz'/) 
 common/nmstr/emname 
 data emname/'bar','baz'/ 
 !character(len=3) :: emname(nmin)=(/'bar','baz'/) 
 end block data thdinit


-- 
           Summary: Initialization/declaration problems in block data
           Product: gcc
           Version: 4.1.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ruedas at dtm dot ciw dot edu


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

Reply via email to