This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/17678] New: USE statement incorrectly initializes allocatable array


% gfortran --static test.f90
% a.out
 oops
Abort (core dumped)

% cat test.f90

module foo
  integer, dimension(:), allocatable :: bar
end module

program main
  use foo
  allocate (bar(100))
  call init
end program main

subroutine init
  use foo
  if (.not.allocated(bar)) then
     print *, 'oops'
     call abort
  endif
end subroutine init

=====================================

And here is the dump-tree-original, which clearly shows the problem:

init ()
{
  extern struct array1_int4 bar;

  bar.data = 0B;           <<<<<<<<<<<<<<<<< ALLOCATION IS LOST HERE
  if (bar.data != 0B == 0)
    {
      _gfortran_filename = "test.f90";
      _gfortran_line = 14;
      _gfortran_ioparm.unit = 6;
      _gfortran_ioparm.list_format = 1;
      _gfortran_st_write ();
      _gfortran_transfer_character ("oops", 4);
      _gfortran_st_write_done ();
      _gfortran_abort ();
    }

-- 
           Summary: USE statement incorrectly initializes allocatable array
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lei at il dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]