[Bug fortran/47601] [OOP] Internal Error: mio_component_ref(): Component not found

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat May 28 15:21:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47601

--- Comment #20 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-28 15:12:26 UTC ---
Valgrind shows:
==9238== Invalid read of size 8
==9238==    at 0x55AFD9: gfc_use_derived (symbol.c:1942)
==9238==    by 0x55B126: gfc_find_component (symbol.c:2002)
==9238==    by 0x55B24A: gfc_find_component (symbol.c:2015)
==9238==    by 0x520B40: mio_ref (module.c:2359)

In gfc_use_derived, sym == NULL - thus, it is not surprising that
sym->components gives an ICE.

The bug seems to be in gfc_find_component where the order of sym == NULL and
gfc_use_derived seems to be reverted:

--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -2000,9 +2000,9 @@ gfc_find_component (gfc_symbol *sym, const char *name,
     return NULL;

-  sym = gfc_use_derived (sym);
-
   if (sym == NULL)
     return NULL;

+  sym = gfc_use_derived (sym);
+
   for (p = sym->components; p; p = p->next)
     if (strcmp (p->name, name) == 0)

 * * *

If one combines both patches, all reduced test cases work (comment 8, comment
11 and comment 13) and also the segfault is gone. However, in the last file of
the compilation series, one now gets:

gyre_lanr.f90:6.19:

  use gyre_lanr_bvp
                   1
Interner Fehler bei (1):
mio_component_ref(): Component not found

 * * *

Note: For that ICE, the flag -std=f2003 is crucial. If I compile
gyre_lanr_bvp.f90 without it, I do not get an ICE. I have not checked whether
that's by chance (memory layout or similar).



More information about the Gcc-bugs mailing list