Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

ifort 16.0.3 bug with unlimited polymorphism

$
0
0

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


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>