llvm / llvm/llvm-project

[Flang] Wrong result for changeable formatted I/O sign mode, between OPEN and INQUIRE

Open
#192,913 2 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

Flang returns incorrect value when querying the SIGN mode of a file opened with SIGN='PROCESSOR_DEFINED'. The INQUIRE statement reports 'SUPPRESS' instead of 'PROCESSOR_DEFINED'.

Expected Behavior: When a file is opened with SIGN='PROCESSOR_DEFINED', a subsequent INQUIRE statement should report the SIGN mode as 'PROCESSOR_DEFINED'. The INQUIRE statement should report the mode that was specified, not convert it to a different value.

Actual Behavior: INQUIRE reports SIGN='SUPPRESS' instead of SIGN='PROCESSOR_DEFINED'.

Reproducer:
```fortran
program test
character(32) out
open(21,STATUS='SCRATCH',SIGN='PROCESSOR_DEFINED')
inquire(21,SIGN=out)
if (out/='PROCESSOR_DEFINED') then
print *,'after OPEN with SIGN="PROCESSOR_DEFINED", INQUIRE reports SIGN="',TRIM(out),'".'
else
print '("ok")'
end if
end

```

Contributor guide

Open the contributing guide

Research direction

Start by running the Fortran reproducer with Flang and trace the OPEN and INQUIRE handling of the SIGN mode. Inspect where SIGN='PROCESSOR_DEFINED' is stored and reported; done means INQUIRE returns 'PROCESSOR_DEFINED' after the OPEN, while other SIGN modes remain correct.

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
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.