llvm / llvm/llvm-project

[Flang] The maximum length of linked lists is shorter than other Fortran compilers

Open
#205,259 0 comments 0 reactions 0 assignees View on GitHub
flang
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The maximum length of linked lists seems to be lower in Flang compared to other compilers (gfortran, ifx). Consider the following program:

```fortran
program main
implicit none
type t
real :: v
type(t), allocatable :: p
end type
call sub
print *, "pass"
contains
subroutine sub
implicit none
integer :: i
integer, parameter :: iter = 10000
type(t), target :: a
type(t), pointer :: head
head => a
head%v = 0
do i = 1,iter
allocate(head%p)
head => head%p
head%v = i
end do
end subroutine sub
end
```

The program execution terminates abnormally with Flang, but not with other compilers:
https://godbolt.org/z/KGro8je4T

If `iter` is 100000, other compilers also fail. If `iter` is 1000, Flang also succeeds.
https://godbolt.org/z/Krzc7s1Er

Contributor guide

Open the contributing guide

Research direction

Start by compiling and running the linked-list reproducer with Flang, using the provided Compiler Explorer links to compare behavior with gfortran and ifx. Vary iter around 1,000, 10,000, and 100,000 to characterize the limit and identify whether the failure is in allocation, pointer handling, or runtime support. Done means the 10,000-node program completes normally without regressing the larger-case behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.