Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
27 Views

Potential compiler bug

Hello,

I might have stumble upon a compiler bug:

!< Tested on Intel® Parallel Studio XE 2017 Update 4 Composer Edition for Fortran Windows (w_comp_lib_2017.4.210))
module my_module
	implicit none
    
    !< A type
    type :: A_type
		real      :: value 
    contains
		procedure :: A_assign_value
		generic   :: assignment(=) => A_assign_value
    end type A_type
    
    !< B type
	type, extends(A_type) :: B_type
    end type B_type
    
    !< C type
    type :: C_type
        real         :: x
        type(A_type) :: A
        type(B_type) :: B
    end type C_type	
	
    !< D type
    type :: D_type
        real         :: x
        type(B_type) :: B
        type(A_type) :: A
    end type D_type	    
	
contains

	subroutine A_assign_value(this, value) 
		class(A_type), intent(inout) :: this
		real         , intent(in)    :: value
		this%value = value
    end subroutine A_assign_value
	
end module my_module
    
    
program bug_test
    use my_module
    implicit none
    type(C_type) :: C
    type(D_type) :: D
                
    C = C_type(1.0, A_type(1.0), B_type(1.0))         
    D = D_type(1.0, B_type(1.0), A_type(1.0)) 
        
    write(*,*) C%x, D%x !<                                   out: 1.0  0.0  
                        !< By commenting out lines 9 and 10, out: 1.0  1.0 
end program bug_test

 

Thank you.

Nick

0 Kudos
0 Replies