------- Comment #3 from burnus at gcc dot gnu dot org 2007-04-15 18:39 ------- Minimal example:
program test implicit none type data_type integer :: i=2 end type data_type type(data_type) :: d d%i = 4 call set(d,d) contains subroutine set(x1,x2) type(data_type),intent(out):: x1 type(data_type),intent(in) :: x2 x1%i = x2%i end subroutine set end program test Hereby, d%i = 4 call set(d,d) is translated into: d.i = 4; { struct data_type data_type.0; data_type.0.i = 2; d = data_type.0; } set (&d, &d); If one removes the "intent(out)" for x1, data_type.0 is not created and everything is fine. If one creates a temporary structure, shouldn't one have something like the following? (Handcrafted) d.i = 4; { struct data_type data_type.0; data_type.0.i = 2; set (&data_type.0, &d); d = data_type.0; } There is actually a difference how gfortran and how g95 and NAG f95 do the default initialization. For the following Fortran code program test implicit none type data_type integer :: i=2 end type data_type type(data_type) :: d d%i = 4 call set(d) print *, d%i contains subroutine set(x1) type(data_type),intent(out):: x1 end subroutine set end program test "2" is printed (by all compilers). gfortran does: d.i = 4; { struct data_type data_type.0; data_type.0.i = 2; d = data_type.0; } set (&d); set (x1) { (void) 0; whereas g95 does: d.i = 4; set_ (&d);; set_ (x1) { int4 D.470; D.470 = 0; if (x1 != 0B) *x1 = {.i=2}; return D.470;; analogously does NAG f95: d_.i_ = 2; d_.i_ = 4; test_IP_set(&d_); static void test_IP_set(x1_) struct test_DT_data_type *x1_; { x1_->i_ = 2; Though, I don't know which method is better. -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu dot | |org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31205