lfortran / lfortran

Official main repository for LFortran
https://lfortran.org/
Other
977 stars 160 forks source link

T not allowed in format string #3957

Closed harperjf closed 6 months ago

harperjf commented 7 months ago

Having found that lfortran would not allow T in a format string (valid Fortran ever since f77) I wrote this little program to check my workaround, which 5 other compilers all allowed. But if I tried compiling with the -g --debug-with-line-column options as recommended when I just tried -g, I got an ICE as I did in #3900, although this time no allocatable scalar was involved. I quote the Fortran program and its outputs with various options. The output was useful only with no options at all specified!


(lf2) john:~/Test$ cat fmtbug.f90
program fmtbug
  character fmt*26, line*80
  fmt =  '(1X,A,T33,A4,6X,99(A5,6X))'
  write(line,fmt) 'a','b','c','d','e'
  print "(A)", trim(line)
  write(line,"(1X,A,A4,6X,99(A5,6X))") 'a'//repeat(' ',30), 'b','c','d','e'
  print "(A)", trim(line)
end program fmtbug
(lf2) john:~/Test$ lfortran fmtbug.f90
Unsupported or unrecognized `T` in format string
(lf2) john:~/Test$ lfortran -g  fmtbug.f90
semantic error: The `emit_debug_line_column` is not enabled; please use the `--debug-with-line-column` option to get the correct location information

Note: Please report unclear or confusing messages as bugs at
https://github.com/lfortran/lfortran/issues.
(lf2) john:~/Test$ lfortran -g --debug-with-line-column fmtbug.f90
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x726858
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", local address: 0x29e3f
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", local address: 0x29d8f
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x600a58
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x7a0a5c
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x78ded9
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x85f731
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x1c0d4b8
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x1c06678
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x1c03c9f
  Binary file "/home/john/conda_root/envs/lf2/bin/lfortran", local address: 0x1ba108d
LCompilersException: Debug information for the type: `str` is not yet implemented
(lf2) john:~/Test$ 
certik commented 7 months ago

Yes, the -g --debug-with-line-column options don't work in all cases yet. In terms of priorities we'll work on debugging symbols after we reach beta.

Regarding the T format descriptor, we just have to implement it. It needs to be added here: https://github.com/lfortran/lfortran/blob/60d158479f925afe9b00013e4e152e604b925b19/src/libasr/runtime/lfortran_intrinsics.c#L487. Do you want to send us a patch?

harperjf commented 7 months ago

Sorry, I know something about Fortran but I'm totally ignorant of LLVM and of C, which I suspect your 60d1584 is written in.

certik commented 7 months ago

@harperjf no worries. The best way you can help then is to report bugs, as you have been doing. Thank you.