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/15273] [gfortran] Wrong output from a pure subroutine


------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de  2004-05-04 13:44 -------
It's quite interesting to see how this problem comes to happen: 
I used this slightly revised test program: 
[tobi@marktplatz tests]$ cat pr15273.f90
program testp
integer, parameter :: intp = 3
integer :: j
call subx(intp,j)
print *, intp, j
call suby(intp,j)
print *, intp, j
contains
pure subroutine subx(i,iout)
integer, intent(in) :: i
integer, intent(out) :: iout
iout = i + 1
end subroutine subx
  
subroutine suby(i,iout)
integer, intent(in) :: i
integer, intent(out) :: iout
iout = i + 1
end subroutine suby
end program testp

compiling with "gfortran pr15273.f90 -fdump-tree-all" yields these dumps:
[tobi@marktplatz tests]$ cat pr15273.f90.t03.original
suby (i, iout)
{
  *iout = *i + 1;
 
 
subx (i, iout)
{
  *iout = *i + 1;
 
 
MAIN__ ()
{
  int4 j;
  static  subx;
  static  suby;
 
  {
    int4 T.4;
 
    T.4 = 3;
    subx (&T.4, &j);;
  }
  _gfortran_filename = "pr15273.f90";
  _gfortran_line = 5;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  {
    int4 T.5;
 
    T.5 = 3;
    _gfortran_transfer_integer (&T.5, 4);;
  }
  _gfortran_transfer_integer (&j, 4);
  _gfortran_st_write_done ();
  {
    int4 T.6;
 
    T.6 = 3;
    suby (&T.6, &j);;
  }
  _gfortran_filename = "pr15273.f90";
  _gfortran_line = 7;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  {
    int4 T.7;
 
    T.7 = 3;
    _gfortran_transfer_integer (&T.7, 4);;
  }
  _gfortran_transfer_integer (&j, 4);
  _gfortran_st_write_done ();;
}
 
 
[tobi@marktplatz tests]$ cat pr15273.f90.t13.lower
 
;; Function subx (subx.1)
 
subx (i, iout)
{
  int4 T.3;
  int4 T.2;
 
  T.2 = *i;
  T.3 = T.2 + 1;
  *iout = T.3;
}
 
 
 
;; Function suby (suby.0)
 
suby (i, iout)
{
  int4 T.1;
  int4 T.0;
 
  T.0 = *i;
  T.1 = T.0 + 1;
  *iout = T.1;
}
 
 
 
;; Function MAIN__ (MAIN__)
 
MAIN__ ()
{
  int4 T.7;
  int4 T.6;
  int4 T.5;
  int4 T.4;
  int4 j;
 
  T.4 = 3;
  _gfortran_filename = "pr15273.f90";
  _gfortran_line = 5;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  T.5 = 3;
  _gfortran_transfer_integer (&T.5, 4);
  _gfortran_transfer_integer (&j, 4);
  _gfortran_st_write_done ();
  T.6 = 3;
  suby (&T.6, &j);
  _gfortran_filename = "pr15273.f90";
  _gfortran_line = 7;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  T.7 = 3;
  _gfortran_transfer_integer (&T.7, 4);
  _gfortran_transfer_integer (&j, 4);
  _gfortran_st_write_done ();
}

the interesting part is that in the lowered tree, the call to the pure
subroutine has disappeared. That's why j is uninitialized. Now I don't know if
that's a legal transformation, but I think it is.

-- 


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


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