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

More problems with complex array parts

NCarlson
New Contributor II
416 Views

I've encountered another problem involving complex array parts with ifx 2025.1. Here's an example:

type :: foo
  complex :: z(3)
end type
type(foo) :: a
call bar(a%z%re)
contains
  subroutine bar(x)
    real, intent(inout) :: x(:)
  end subroutine
end

The compiler gives this spurious error. The actual argument is very clearly neither a constant or expression.

$ ifx bug.f90 
bug.f90(5): error #6638: An actual argument is an expression or constant; this is not valid since the associated dummy argument has the explicit INTENT(OUT) or INTENT(INOUT) attribute.
call bar(a%z%re)
---------^
compilation aborted for bug.f90 (code 1)

Trying to work around this via an ASSOCIATION block results in an ICE:

type :: foo
  complex :: z(3)
end type
type(foo) :: a
associate (z => a%z)
  call bar(z%re)
end associate
contains
  subroutine bar(x)
    real, intent(inout) :: x(:)
  end subroutine
end
$ ifx bug.f90 
          #0 0x0000000003310581
          #1 0x0000000003375357
         [...]
         #28 0x00007f74839d320b __libc_start_main + 139
         #29 0x000000000308f0ee

bug.f90(6): error #5623: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
  call bar(z%re)
-----------^
compilation aborted for bug.f90 (code 3)

Another work around attempt using an ASSOCIATE block compiles without error, but produces invalid results.

type :: foo
  complex :: z(3)
end type
type(foo) :: a
a%z%re = -1
associate (z_re => a%z%re)
  call bar(z_re)
end associate
print *, a%z%re
if (any(a%z%re /= [1,2,3])) stop 'fail'
contains
  subroutine bar(x)
    real, intent(inout) :: x(:)
    x = [1,2,3]
  end subroutine
end
$ ifx bug.f90 
$ ./a.out
  -1.000000      -1.000000      -1.000000    
fail

The only workaround I've found that works is to manually do copy-in/copy-out of the complex array part to a real array temporary.

0 Kudos
0 Replies
Reply