[Bug fortran/45170] New: suspected bug in error generated by allocatable character array

clerman at fuse dot net gcc-bugzilla@gcc.gnu.org
Tue Aug 3 01:55:00 GMT 2010


gfortran tech support,

  When I attempt to compile the program listed below, the following error
messages are printed:

norm@oxford:~/Elements/AllocChar$ more alloccharP.xyz 
alloccharP.f90:6.12:

  character(:), allocatable :: c_Char(:)
            1
Error: Syntax error in CHARACTER declaration at (1)
alloccharP.f90:7.12:

  character(:), allocatable :: io_message
            1
Error: Syntax error in CHARACTER declaration at (1)

  I searched the bug database but could not find this bug listed.

 I am attempting to declare an array of allocatable characters, which I believe
is legal. The Intel 12.0 beta compiler and version 5.2 of the nag compiler both
compile this routine. (The routine, as written, is not correct: the variable
io_message needs to be allocated before it is used in the open statement.)

  Thank you for your attention.

Yours truly,

Norm

Norman S. Clerman

program AllocChar

  integer, parameter :: CHAR_ELEMENTS = 5, FILE_UNIT = 11
  integer :: io_stat
!  character(:), allocatable :: c_Char(CHAR_ELEMENTS)
  character(:), allocatable :: c_Char(:)
  character(:), allocatable :: io_message
  character (*), parameter :: FILE_NAME = "no_file.dat"

!  io_message = "no errors"
!  print *, io_message
!  c_Char = " "
!  c_Char(1: 2) = ["Hello     ", " everyone!"]
!  c_Char(1) = "Hello"
!  c_Char(2) = "everyone"
!  print *, c_Char (1: 2)

  open (unit = FILE_UNIT, file = FILE_NAME, iostat = io_stat, iomsg =
io_message, status = "old")

  print *, io_message

end program AllocChar


-- 
           Summary: suspected bug in error generated by allocatable
                    character array
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: clerman at fuse dot net


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



More information about the Gcc-bugs mailing list