------- Comment #7 from dominiq at lps dot ens dot fr  2010-09-08 15:52 -------
The following code reduced from 

module type2_type 
 implicit none 
 type, abstract :: Type2 
    character :: typeName*(30) = "unknown" 
 end type Type2 
 end module type2_type 

 module extended2A_type 
 use type2_type 
 implicit none 
 type, extends(Type2) :: Extended2A 
    real(kind(1.0D0)) :: coeff1 = 1. 
    real(kind(1.0D0)) :: coeff2 = 2. 
    procedure :: setCoeff1 => Extended2A_setCoeff1 
 end type Extended2A 
    function Extended2A_new(c1, c2) result(typePtr_) 
       real(kind(1.0D0)), optional, intent(in) :: c1 
       real(kind(1.0D0)), optional, intent(in) :: c2 
       type(Extended2A), pointer  :: typePtr_ 
       type(Extended2A), save, allocatable, target  :: type_ 
       typePtr_ => null() 
       if (present(c1)) call type_%setCoeff1(c1) 
       typePtr_ => type_ 
       if ( .not.(associated (typePtr_))) then 
          stop 'Error initializing Extended2A Pointer.' 
    end function Extended2A_new 
    subroutine Extended2A_setCoeff1(this,c1) 
       class(Extended2A) :: this 
       real(kind(1.0D0)), intent(in) :: c1 
       this% coeff1 = c1 
    end subroutine Extended2A_setCoeff1 
 end module extended2A_type 

 module type1_type 
 use type2_type 
 implicit none 
 type Type1 
    class(type2), pointer :: type2Ptr => null() 
    procedure :: initProc => Type1_initProc 
 end type Type1 
    function Type1_initProc(this) result(iError) 
       use extended2A_type 
       implicit none 
       class(Type1) :: this 
       integer :: iError 
          this% type2Ptr => extended2A_new() 
          if ( .not.( associated(this% type2Ptr))) then 
             iError = 1 
             write(*,'(A)') "Something Wrong." 
             iError = 0 
    end function Type1_initProc 
 end module type1_type 

 program main 
 use type1_type 
 use extended2A_type 
 implicit none 
 integer :: iErr, i 
 integer :: numArgs 
 character, dimension(:), allocatable :: tempArgs*(100) 
 class(type1), allocatable :: thisType1 
 allocate (Type1::thisType1) 
 iErr = thisType1%initProc() 
 deallocate (thisType1% type2Ptr)  ! What happens here???  See questions below. 
! now the pointer should be dangling and needs to be nullified / reassigned 
 end program main 

gives a segmentation fault when compiled with revision 163966 without the patch
in comment #5, backtrace

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
0x00000001000c6120 in gfc_trans_structure_assign (dest=0x142504cc0) at
4436          tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE
(gdb) bt
#0  0x00000001000c6120 in gfc_trans_structure_assign (dest=0x142504cc0) at
#1  0x00000001000c692a in gfc_trans_structure_assign (dest=0x142503c80) at

while it compiles at revision 164002 with the patch. I'll try to revert the
patch tonight to see if the gone ICE is due to it.



Reply via email to