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

ifort 16.0.3 bug with unlimited polymorphism

Melven_R_
Beginner
353 Views

Dear Intel support team

For the following code I obtain an error:

program test
  implicit none
  type SomeType
    real, pointer, contiguous :: x(:) => null()
  end type
  type(SomeType) :: t

  allocate(t%x(10))
  call doSomething(t)
  write(*,*) t%x
contains

  subroutine doSomething(myT)
    class(*), intent(in) :: myT

    select type(myT)
    type is (SomeType)
      ! not allowed!
      ! myT%x => null()

      ! allowed!
      myT%x = 7.

      ! workaround
      call assign7(myT%x)

    class default
      write(*,*) 'error'
      call exit(1)
    end select

  end subroutine

  subroutine assign7(x)
    real, intent(out) :: x(:)
    x = 7
  end subroutine

end program test

The error message shown is:

> ifort --version
ifort (IFORT) 16.0.3 20160415
> ifort test.f90 
test.f90(22): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [MYT]
      myT%x = 7.
------^
compilation aborted for test.f90 (code 1)

As x is a pointer changing its value should be allowed though. Everything works fine, when "myT" is just declared as "type(SomeType), intent(in)" (without using "class(*)" polymorphism)!

As a workaround it is possible to call a subroutine to modify "myT%x"...

Regards

Melven

0 Kudos
1 Solution
Xiaoping_D_Intel
Employee
353 Views

Thanks for reporting the error. It no longer happens with 17.0 compiler which will be released very soon.

 

Thanks,

Xiaoping Duan

Intel Customer Support

View solution in original post

0 Kudos
1 Reply
Xiaoping_D_Intel
Employee
354 Views

Thanks for reporting the error. It no longer happens with 17.0 compiler which will be released very soon.

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Reply