https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96158
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
% cat b.f90
module somemodule
integer*8 moduleVar
common /othermodule/ moduleVar
end module
% cat a.f90
program myprogram
use somemodule
moduleVar = 123
call boo
end program
subroutine boo
integer*8 n
common /othermodule/n
write(*, '(A, I3)') "moduleVar=", n
end
% nm -a b.o
00000000 b .bss
00000000 n .comment
00000000 d .data
00000000 N .debug_abbrev
00000000 N .debug_aranges
00000000 N .debug_info
00000000 N .debug_line
00000000 N .debug_str
00000000 n .note.GNU-stack
00000000 t .text
00000000 a b.f90
00000008 C othermodule_
The last line is what you're looking for.
% gfcx -g -o z b.f90 a.f90
% gdb ./z
(gdb) b main
Breakpoint 1 at 0x804867b: file a.f90, line 2.
(gdb) b boo
Breakpoint 2 at 0x80485ad: file a.f90, line 9.
(gdb) run
Starting program: /usr/home/kargl/tmp/z
Breakpoint 1, main (argc=1, argv=0xffbfe7f0) at a.f90:2
2 use somemodule
(gdb) p moduleVar
No symbol "moduleVar" in current context.
(gdb) p (integer*8)othermodule_
$1 = 0
(gdb) c
Continuing.
Breakpoint 2, boo () at a.f90:9
9 write(*, '(A, I3)') "moduleVar=", n
(gdb) p n
$2 = 123
(gdb) p moduleVar
No symbol "moduleVar" in current context.
(gdb) p (integer*8)othermodule_
$3 = 123
I won't comment on the questionable programming idiom of placing
a common block in a module, which kind of defeats the niceties of
a module.