lfortran icon indicating copy to clipboard operation
lfortran copied to clipboard

transfer miscounting?

Open harperjf opened this issue 2 years ago • 2 comments

In an attempt to work around the problem reported in #3960 I tried to convert a string of 26 characters into an array of 26 single characters but transfer seems to have converted it into an array of 64 elements. It compiled and ran with other compilers but this is what lfortran (aliased to lf in my system) did with it.

(lf2) john:~/Test$ cat fmtbugb.f90
program fmtbugb
  character(1) fmt*10, line*80, lstring*26, larray(26)
  integer i
  lstring = 'abcdefghijklmnopqrstuvwxyz'
  larray = transfer(lstring,larray)
  fmt = '(99(1X,A))'
  write(line,fmt) (larray(i), i=1,26)
  print "(A)", trim(line)
end program fmtbugb
(lf2) john:~/Test$ lf fmtbugb.f90
semantic error: Different shape for array assignment on dimension 1(26 and 64)
 --> fmtbugb.f90:5:3
  |
5 |   larray = transfer(lstring,larray)
  |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 


Note: Please report unclear or confusing messages as bugs at
https://github.com/lfortran/lfortran/issues.
(lf2) john:~/Test$ 

harperjf avatar May 04 '24 08:05 harperjf

We still have this error with latest main.

Pranavchiku avatar May 02 '25 06:05 Pranavchiku

This works with the main. Let's add a test to close this issue.

% lfortran a.f90
 a b c d e f g h i j k l m n o p q r s t u v w x y z
% gfortran a.f90 && ./a.out
 a b c d e f g h i j k l m n o p q r s t u v w x y z

HarshitaKalani avatar Feb 19 '26 16:02 HarshitaKalani