Empty contains region triggers Lowering Error

Hello,
I found an issue where operations on a derived type array in combination with an empty contains region lead to a Lowering Error.

A minimal example which triggers this is here:

program p1

  implicit none

  type foo
     integer :: i
  end type foo

  type(foo) :: bar(5)

  bar(:)%i = 1
  print *, 'bar:', bar%i

contains

end program p1

Compiling with nvfortran (24.7) gives the error message:
Lowering Error: allocate with no array size [ast=57,asttype=38,datatype=0]

I found two solutions to remedy the issue:

  1. Make bar(:) an allocatable
  type(foo), allocatable :: bar(:)
  allocate(bar(5))
  1. Just remove the contains statement

Similar issues occur where the contains statement is part of a subroutine.
This issue has an easy fix, but I assume the root of the problem lies deeper than the contains statement.

FWIW, the code compiles and run with Flang ( as you are now probably aware, nvfortran will be replaced by a new compiler based on Flang).

I will let Mat comments on the issue in nvfortran.

1 Like

FYI: The same issue was already reported here: ICE: Lowering Error: allocate with no array size ref: TPR#35797. I wonder if there is any update on a possible fix or further, is there any public schedule on replacing nvfortran with other compiler based on Flang?

Yes, I missed that post. Seems to be the same issue.

Unfortunately we can’t disclose timelines, but things are progressing. However, engineering is deferring fixing some nvfortran issues, and it appears TPR#35797 is in this category. If something is critical and you don’t have viable workaround, let me know and I can talk to management.

1 Like