This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: segfault in translate_common()
Bernhard,
If you comment out one of "toggle", the segfault goes away.
This example shows that your two toggles are not equivalent;
module mod0
double complex FOO
common/bar/FOO
contains
subroutine eyeore ()
FOO = FOO + (1.0d0, 0.0d0)
end subroutine eyeore
end module mod0
module mod1
! use mod0 ! toggle
end module mod1
module mod2
use mod0 ! toggle
use mod1
contains
subroutine tigger ()
print *, FOO
end subroutine tigger
end module mod2
use mod2
FOO = (0.0d0, 1.0d0)
call eyeore ()
call tigger ()
end
The assignment in the main program does not transmit to either
subroutine. With the toggle, as shown, eyeore succeeds in adding (1,0)
to the FOO, seen by tigger. With the other toggle, poor old tigger sees
nothing at all.
Printing out the parse tree shows that common blocks like /bar/,
/_0_bar/, /_1__0_bar/ and /_2__1__0_bar/ are in circulation.
Read_module is obviously failing to check if there is already a common
block of the same name that has been previously use associated.
The patch below fixes your problem but "perturbs" my fix for module
equivalences; the test cases work perfectly but the module equivalences
to common variables manage to be associated with different external
symbols, which are none the less correctly aligned! I obviously need to
understand this before emitting a patch and a test case. Otherwise it
regtests on FC3/Athlon.
If this turns out to be a valid fix, gfc_get_common can be simplified
and the second argument removed, since it is now always zero.
Best regards
Paul T
Index: gcc/gcc/fortran/module.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/module.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 module.c
*** gcc/gcc/fortran/module.c 25 Jun 2005 00:40:35 -0000 1.34
--- gcc/gcc/fortran/module.c 11 Aug 2005 14:22:45 -0000
*************** Software Foundation, 51 Franklin Street,
*** 2908,2914 ****
mio_lparen ();
mio_internal_string (name);
! p = gfc_get_common (name, 1);
mio_symbol_ref (&p->head);
mio_integer (&p->saved);
--- 2908,2914 ----
mio_lparen ();
mio_internal_string (name);
! p = gfc_get_common (name, 0);
mio_symbol_ref (&p->head);
mio_integer (&p->saved);