llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.31k stars 11.69k forks source link

[flang][AIX] zero-sized array crash #110913

Open kkwli opened 2 days ago

kkwli commented 2 days ago

Reproducer

  integer, allocatable :: a(:)
  allocate(a(0))
  inquire(iolength=iol) a
end
$ flang-new zero.f90
$ ./a.out

fatal Fortran runtime error(/home/kli/zero.f90:3): Bad address for I/O item -- null base address or subscripts out of range
IOT/Abort trap (core dumped)

Original test: https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/torture/execute/iolength_1.f90

llvmbot commented 2 days ago

@llvm/issue-subscribers-flang-runtime

Author: Kelvin Li (kkwli)

Reproducer ```fortran integer, allocatable :: a(:) allocate(a(0)) inquire(iolength=iol) a end ``` ``` $ flang-new zero.f90 $ ./a.out fatal Fortran runtime error(/home/kli/zero.f90:3): Bad address for I/O item -- null base address or subscripts out of range IOT/Abort trap (core dumped) ``` Original test: https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/torture/execute/iolength_1.f90
llvmbot commented 2 days ago

@llvm/issue-subscribers-bug

Author: Kelvin Li (kkwli)

Reproducer ```fortran integer, allocatable :: a(:) allocate(a(0)) inquire(iolength=iol) a end ``` ``` $ flang-new zero.f90 $ ./a.out fatal Fortran runtime error(/home/kli/zero.f90:3): Bad address for I/O item -- null base address or subscripts out of range IOT/Abort trap (core dumped) ``` Original test: https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/torture/execute/iolength_1.f90
DanielCChen commented 2 days ago

There is another variation that could be caused by the same issue.

program main
  real, allocatable :: a1(:)
  allocate( a1(2:1) )
  a1 = real(4, 8)
end

fatal Fortran runtime error(/home/cdchen/temp/b.f:4): Assign: mismatched ranks (1 != 0) in assignment to unallocated allocatable
IOT/Abort trap(coredump)