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

ICE on invalid specification expression using SIZE

Harald1
New Contributor II
536 Views

Hello,

the following invalid code ICEs with current ifort/ifx:

program bug
  implicit none
  print *, f([1.])
contains
  function f(b)
    real, intent(in) :: b(:)
    real, pointer    :: c(:)
!   real             :: f(size(b)) ! <-- This would be valid
    real             :: f(size(c)) ! <-- This is invalid
  end
end

I get:

% ifort ifort-bad-specification.f90
ifort-bad-specification.f90(5): warning #6178: The return value of this FUNCTION has not been defined.   [F]
  function f(b)
-----------^
ifort-bad-specification.f90(9): catastrophic error: **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.
compilation aborted for ifort-bad-specification.f90 (code 1)

 and a similar ICE with traceback for ifx.  Replacing "pointer" by "allocatable" gives the same crash, as well as other ranks than 1 except for c being a scalar.

Likely an error recovery issue in the compiler.

 

1 Solution
Barbara_P_Intel
Moderator
267 Views

The ICE melted from this reproducer with the 2024.1 compilers that were released last week.

Please give the new ifx and ifort a try.



View solution in original post

0 Kudos
4 Replies
Barbara_P_Intel
Moderator
502 Views

Thank you for reporting this with a great reproducer and the extra insight!

I filed a bug report, CMPLRLLVM-49873. I'll post when a fix is available.



0 Kudos
Barbara_P_Intel
Moderator
478 Views

One of the compiler engineers took an initial look at this and points out, "By Fortran rules, local variable C is completely undefined.  That is, the initial state for a pointer is 'undefined'.  Its size would be completely random. So, while it's Not Nice (tm) that we give an ICE at compile time, the program is invalid and likely gives a segfault at runtime."



0 Kudos
Barbara_P_Intel
Moderator
268 Views

The ICE melted from this reproducer with the 2024.1 compilers that were released last week.

Please give the new ifx and ifort a try.



0 Kudos
Harald1
New Contributor II
229 Views

Thanks for fixing this!

 

0 Kudos
Reply