------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-11-05 23:46 
-------
Hey, it crashes Intel, Sun, g95 and gives a runtime error with Portland. Not
bad!

Reduced testcase:

program test
  interface
  function my_string(x)
    integer, intent(in) :: x
    integer :: sv(x)
    character(size(sv)) my_string
  end function my_string
  end interface

  integer x
  write(*,*) my_string(x)
end program test

The following one triggers a slightly different ICE, most probably has the same
cause:

program test
  integer x
  write(*,*) my_string(x)
contains
  function my_string(x)
    integer, intent(in) :: x
    integer :: sv(x)
    character(size(sv)) my_string
  end function my_string
end program test

The reason for the failure is apparent from the tree dump:

    test ()
    {
      char[1:MAX_EXPR <D.876, 0>] * pstr.5;
      int4 D.876;
      ...
      D.875 = &parm.4;
      D.876 = (int4) _gfortran_size0 (D.875);
      D.878 = MAX_EXPR <D.876, 0>;
      ...
      pstr.5 = (char[1:MAX_EXPR <D.876, 0>] *) D.879;
      my_string (pstr.5, MAX_EXPR <D.876, 0>, D.860);
      _gfortran_transfer_character (&dt_parm.1, pstr.5, MAX_EXPR <D.876, 0>);
    }

When we're declaring pstr.5, we don't know yet what length it's gonna have, so
we probably need to make it a simple char *, instead of being clever. I hope
this can put someone on the right track about how to fix this.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-05 23:46:09
               date|                            |


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

Reply via email to