Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28434 Discussions

Internal compiler errors with parametric objects (constructors, operators)

Trent_Hawkins
Novice
272 Views

Regards Parallel Studio XE 2017 update 1

I tried to shorten the code snippet as much as possible:

#     ifndef matrix_algebra_F90
#     define matrix_algebra_F90

      module matrix_algebra

            implicit none

            integer,parameter::x_=8
            type::matrix(size)
               integer,len::size
               complex(kind=x_)::component(0:size,0:size)
            contains
               procedure,private::initialize_matrix
               procedure,private::initialize_matrix_factor
        end type  matrix

            interface matrix
               module procedure matrix_zeroes_constructor
               module procedure matrix_factor_constructor
        end interface matrix
            interface operator(*)
               module procedure matrix_matrix_matrix_contraction
        end interface operator(*)

      contains

            subroutine initialize_matrix(this,source)

                  implicit none

                  class(matrix(*))::this
                  complex(kind=x_),intent(in),optional::source(0:this%size,0:this%size)

                  if(present(source)) then
                     this%component=source
                  else
                     this%component=(0.0_x_,0.0_x_)
              end if!present(source)

        end subroutine initialize_matrix!this,source

            function matrix_zeroes_constructor(size) result(that)

                  implicit none

                  integer,intent(in)::size
                  type(matrix(size))::that

                  call that%initialize_matrix()

        end function matrix_zeroes_constructor!size

            subroutine initialize_matrix_factor(this,factor)

                  implicit none

                  class(matrix(*))::this
                  complex(kind=x_),intent(in)::factor
                  integer::index

                  this%component=(0.0_x_,0.0_x_)
                  do index=0,this%size,+1
                     this%component(index,index)=factor
              end do!index=0,this%size,+1

        end subroutine initialize_matrix_factor!this,factor

            function matrix_factor_constructor(size,factor) result(that)

                  implicit none

                  integer,intent(in)::size
                  complex(kind=x_)::factor
                  type(matrix(size))::that

                  call that%initialize_matrix_factor(factor)

        end function matrix_factor_constructor!size,factor

            function matrix_matrix_matrix_contraction(matrix1,matrix2) result(matrix_)

                  implicit none

                  type(matrix(*)),intent(in)::matrix1
                  type(matrix(*)),intent(in)::matrix2
                  type(matrix(min(matrix1%size,matrix2%size)))::matrix_

                  matrix_%component=matmul(matrix1%component,matrix2%component)

        end function matrix_matrix_matrix_contraction!matrix1,matrix2

            function internal_errors(matrix0) result(matrix_)

                  implicit none

                  type(matrix(*)),intent(in)::matrix0
                  type(matrix(matrix0%size))::matrix_

                  matrix_=matrix(matrix0%size)                 ! OK
            !     matrix_=matrix(matrix0%size,(1.0_x_,0.0_x_)) ! **Internal compiler error: segmentation violation signal raised**
            !     matrix_=matrix_*matrix0                      ! **Internal compiler error: segmentation violation signal raised**

        end function internal_errors!matrix0

  end module matrix_algebra

#     endif

Any of the two commented lines alone in the last (test) function generates an internal compiler error. One uses a custom constructor, the other uses an overloaded operator. The use of the simple constructor runs OK. I think that the other constructor is well defined, as well as the matrix operation. In any case, it should generate a normal compiler error in any other case.

0 Kudos
3 Replies
Xiaoping_D_Intel
Employee
272 Views

Thanks for reporting the issue and I can reproduce it with 17.0 update 1. However, it no longer happens in the latest compiler binaries in development so the next release 17.0 update 2 will built it without error.

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Trent_Hawkins
Novice
272 Views

Thank you! Is there perhaps a time-frame for releasing 17.0.2? I found a workaround and can go about my development, but it would be nice to pass the library to the team with constructor functions. (encapsulation)

0 Kudos
Kevin_D_Intel
Employee
272 Views

17.0 Update 2 target release is late next month (Feb. '17).

0 Kudos
Reply