llvm / llvm/llvm-project

[Flang] Wrong result for namelist output when namelist member is an array

Open
#192,936 1 comment 0 reactions 0 assignees View on GitHub
flang
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Flang writes CHARACTER array elements in NAMELIST output without value separators (commas), producing invalid NAMELIST format that cannot be read back correctly.

Expected Behavior: When writing a CHARACTER array using NAMELIST formatting, array elements should be separated by commas according to the Fortran standard.

Actual Behavior: Array elements are concatenated together without commas, producing output that looks like a single string instead of an array of values.

Reproducer:
```fortran
Program test
Character(Len=1) :: x(10) = [ (Achar(Iachar('0')+i),i=0,9) ]
Namelist/nml/x
Write(*,NML=nml)
End

```

Contributor guide

Open the contributing guide

Research direction

Start by running the Fortran reproducer with Flang and inspect the NAMELIST output for the CHARACTER array x. Compare the result with the expected comma-separated array representation; done means the output is valid NAMELIST format and can be read back correctly.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.