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

Compiler bug involving complex array parts

NCarlson
New Contributor I
318 Views

I've encountered another bug with complex array parts using ifx 2025.1.  Here's a small example.  I'll follow-up with a couple workaround attempts that result in either an internal compiler error or incorrect runtime results. The only workaround I've found that works is to manually do copy-in/copy-out to a temporary real array.

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. Clearly the actual argument is 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)
3 Replies
NCarlson
New Contributor I
314 Views

This attempt at a workaround using 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 0x00007fce2f76b20b __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)

 

 

NCarlson
New Contributor I
313 Views

This attempt at a workaround using an ASSOCIATE block compiles without error, but produces incorrect 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
NCarlson
New Contributor I
276 Views

Here's the more complete test code from my compiler bug database that should compile and run with a 0 exit status (unix).

Reply