Skip to content

[flang] : read character array #118277

@Euler37

Description

@Euler37
  • flang version
flang-new version 19.1.4 (https://github.com/conda-forge/clangdev-feedstock ea701dd210fdae63609dff9e817128a8f9847256)
Target: x86_64-conda-linux-gnu
Thread model: posix
InstalledDir: /home/xxx/miniconda3/envs/lf/bin
Configuration file: /home/xxx/miniconda3/envs/lf/bin/x86_64-conda-linux-gnu.cfg

flang will give the wrong result if len of s is smaller than input data

  • the code
program main
   implicit none
    character(len=1)::s(2)
    read(*,*)s
    print*,s(1)
    print*,s(2)
end program main
$ gfortran 1.f90 && ./a.out
ab cd
a
c
$ flang-new 1.f90 && ./a.out
ab cd
a
b

if len of s is greater equal than input data

program main
   implicit none
    character(len=3)::s(2)
    read(*,*)s
    print*,s(1)
    print*,s(2)
end program main
$ gfortran 1.f90 && ./a.out
ab cd
ab
cd
$ flang-new 1.f90 && ./a.out
ab cd
ab
cd

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions