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

zero sized derived type array constructor

w-vdh
Beginner
559 Views

The code below doesn't compile with ifort on Ubuntu 20.04.4 LTS, returning the error message:

10101_13941

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 ifortbug.f90 (code 1)
module m
  type :: u
    real :: x
  end type
end module

program test
  use m
  type(u), allocatable :: ul(:)
  ul = [u::]
  print *, size(ul)
end program

Compiler details:

$ which ifort
/opt/intel/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort
$ ifort --version
ifort (IFORT) 2021.5.0 20211109
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

 

Labels (1)
0 Kudos
4 Replies
Arjen_Markus
Honored Contributor I
552 Views

The same thing happens on Windows with version 2021.4.0 of the Intel Fortran oneAPI compiler (the classic one).

0 Kudos
FortranFan
Honored Contributor II
540 Views

ICEs are pernicious, hopefully you will find them fixed soon in the compiler.

You will know the workaround you can use is the ALLOCATE statement:

  allocate( ul(0) )

By the way, presume you include default initialization for components in your actual codes which is helpful with array objects that can grow/shrink in size:

  type :: u
    real :: x = 0.
  end type

 

0 Kudos
Arjen_Markus
Honored Contributor I
532 Views

This version is accepted:

  ul = [(ul(i), i = 1,0)]

and gives a size 0 as well. But the explicit allocation is probably a more palatable idiom ;).

0 Kudos
Ron_Green
Moderator
485 Views

I tested the original example with our internal builds.   There is an update compiler coming out "soon" for ifort and ifx.  In this next version ifort still gets an ICE.  IFX in the next release aborts gracefully with:

error #5533: Feature found on this line is not yet supported in ifx 
  ul = [u::]
--------^

 

But we've fixed this and the mainline branches compile this example w/o issue and gives the correct result:

$ ifx repro.f90
$ ./a.out
           0
$ more repro.f90
module m
  type :: u
    real :: x
  end type
end module

program test
  use m
  type(u), allocatable :: ul(:)
  ul = [u::]
  print *, size(ul)
end program

 

There were a number of fixes lately around constructors.  Hard to know which one fixed this.  But it is coming.

 

0 Kudos
Reply