lfortran icon indicating copy to clipboard operation
lfortran copied to clipboard

run-time errors in len and print

Open harperjf opened this issue 2 years ago • 1 comments

This program compiles and runs but list-directed printing omitted the blank space in position 1, and len(foo) was 1. Four other compilers printed 32 32 or 32 32 but lfortran printed 32 1. The program:

program bitsize2
  implicit none
  character(bit_size(666)):: foo
  print *, bit_size(666), len(foo)
end program bitsize2

harperjf avatar Apr 26 '24 02:04 harperjf

This was fixed by #4102 (merged 2024-05-28), which corrected the return type of the bit_size intrinsic.

The exact MRE from the issue body now compiles and runs correctly on current main. Both bit_size(666) and len(foo) return 32, matching gfortran output. Before the fix, len(foo) incorrectly returned 1 when character(bit_size(666)) was used as the length specification.

#9899 adds an integration test using the exact MRE from this issue and will close it.

krystophny avatar Feb 05 '26 23:02 krystophny