As far as I can tell, this is valid Fortran code:
program main
implicit none
type foo
character(len=7) :: int = "Hello, "
end type foo
type(foo) :: f
character(len=5) :: character = "World"
character(len=1) :: real = "!"
print *,f%int
print *,character
print *,real
end program
It compiles in gfortran 9.3 and gives the expected output.
However gdb (version 8.2) refuses to print single variables:
(gdb) p real
Attempt to use a type name as an expression
(gdb) p f%int
A syntax error in expression, near `int'.
I can list all variables:
(gdb) info locals
character = 'World'
f = ( int = 'Hello, ' )
real = '!'
int is a curious case, because int is not actually a type name in Fortran and a local variable named int can be printed by gdb. But a struct member named int as in the example can't be printed. And if a local variable int does not exist, p int results in the same error message as p real, so I suspect its connected. This is also how I came across the problem, because the code base I'm working in has a struct with a member int that aggregates and hides some internal data that I want to look at.
I tried version 9.2 and f%int is printable. The others are the same.
I realize those variable names are questionable, but apart from changing them, which is difficult in this particular code base, is there a way to get gdb to print those variables?