Issue 233231
Summary [flang] FORMAT statement: every backslash in a character string edit descriptor is printed twice
Labels flang
Assignees
Reporter ivan-pi
    When a FORMAT *statement* contains a character string edit descriptor with a backslash, flang prints every backslash twice.

```fortran
! format_backslash.f90
program format_backslash
  implicit none
  write (*, 10)
  write (*, 20)
  write (*, "(1x, 'c\d')")
  print 30, 1.5
10 format (1x, 'a\b')
20 format (1x, 'two \\ backslashes')
30 format (1x, '\alpha = ', f4.1)
end program format_backslash
```

```
$ flang -pedantic format_backslash.f90 && ./a.out
 a\\b
 two \\\\ backslashes
 c\d
 \\alpha =  1.5
```

The backslash character is expected to behave as an ordinary character in a character string edit descriptor:

```
$ gfortran format_backslash.f90 && ./a.out
 a\b
 two \\ backslashes
 c\d
 \alpha =  1.5
```

The `-fbackslash` flag changes the behavior, but is not a valid workaround for this issue:

```
$ flang -pedantic -fbackslash format_backslash.f90 && ./a.out
 a\b
 two \\ backslashes
 cd
 \alpha =  1.5
```

This issue affects Fortran programs that generate output LaTeX markup language.

Found using Claude Opus.  
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to