This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/41869] ICE segfault when reading module file



------- Comment #2 from burnus at gcc dot gnu dot org  2010-02-03 20:40 -------
Paul, maybe you have an idea how to solve this best.

One has two modules, (1) one defines "vs_str" and the other (2) defines
  interface
    module procedure len
  end interface
  PRIVATE :: len
  (and a public interface which uses "len")

Now in a third (3) module, one loads first module (2) and then module (1); when
writing the .mod for (3) one writes the following symbol of module (1):

  pure function vs_str(s) result(vs)
    character(len=*), intent(in) :: s
    character, dimension(len(s)) :: vs

Now when writing the expression for the upper bound of "vs" (viz. "len(s)"),
one has  e->expr_type == EXPR_FUNCTION but e->symtree == NULL, which crashes.

Note: mio_expr calls fix_mio_expr(), which tries to fix it for the intrinsic
"len", but
  e->symtree = gfc_find_symtree (gfc_current_ns->sym_root, fname);
returns NULL.

On solution I see is to create a new symtree and add it in fix_mio_expr via
gfc_get_intrinsic_sub_symbol, but somehow I think "len" should not have
disappeared at the first place.

The crash happens in mio_symtree_ref which simply checks whether the symbol
needs to be written or whether it has been written already. For an intrinsic
fucntion, it does not matter and could thus be skipped (not checked!). For
output, mio_expr then simply writes "0" (for intrinsic function) and "len" (for
the function name) - albeit with accessing the e->symtree. Thus, one could also
modify "EXPR_FUNCTION:" of mio_expr to for e->symtree == NULL and (iomode ==
IO_OUTPUT) but that means some code replication.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]