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/36426] Endless loop in gfc_apply_interface_mapping_to_expr



------- Comment #1 from burnus at gcc dot gnu dot org  2008-06-07 16:47 -------
Backtrace:

in gfc_getmem (n=40) at gcc/fortran/misc.c:37
in gfc_get_interface_mapping_charlen   at gcc/fortran/trans-expr.c:1485
in gfc_apply_interface_mapping_to_expr at gcc/fortran/trans-expr.c:1920
in gfc_apply_interface_mapping_to_expr at gcc/fortran/trans-expr.c:1955
[... last two lines repeat several times ...]
in gfc_finish_interface_mapping        at gcc/fortran/trans-expr.c:1695
in gfc_conv_function_call              at gcc/fortran/trans-expr.c:2637

In gfc_apply_interface_mapping_to_expr, first a EXPR_FUNCTION with expr->name
"__len_1_i4" is mapped; then a BT_CHARACTER EXPR_VARIABLE, then a function
"__len_1_i4" then ...

Line 1955 is:
    case EXPR_FUNCTION:
      for (actual = expr->value.function.actual; actual; actual = actual->next)
        gfc_apply_interface_mapping_to_expr (mapping, actual->expr);

Line 1920 is:
  if (expr->ts.type == BT_CHARACTER && expr->ts.cl)
    {
      expr->ts.cl = gfc_get_interface_mapping_charlen (mapping, expr->ts.cl);

  * * *

The essential part of the bug is that the length of the return value depends on
the dummy argument. Reduced test:

  interface
    function foo(x)
     character(len=len(x)) :: foo,x
    end function foo
  end interface
  character(len=20) :: str
  str = foo("Hello")
  end

Important is that both foo and x are "len(x)", if x has len=*, it works.

At the end the call looks / should look like
  foo ((character(kind=1)[1:5] *) &str.1, 5, D.1017, 5);
(as generated with "(len=*) :: x")


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.3.0 4.4.0
            Summary|Compiling tiny prog: Stack  |Endless loop in
                   |overflow; uses PROCEDURE    |gfc_apply_interface_mapping_
                   |                            |to_expr


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


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