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

Another problem with complex array parts

NCarlson
New Contributor I
617 Views

I've encountered another problem involving complex array parts with ifx 2025.1. Here's a small 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 reports this error. The actual argument is very clearly neither a constant nor an 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)

Attempting to work around this bug with an ASSOCIATE block results in an internal compiler error:

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 0x00007f4daaf8020b __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 ASSOCIATION block compiles without error but produces incorrect results when run:

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 work around I've found is to manually do copy-in/copy-out of the real part to a temporary real array.

 

Labels (1)
0 Kudos
0 Replies
Reply