------- Comment #2 from burnus at gcc dot gnu dot org  2007-12-20 10:57 -------
    at /projects/tob/gcc/gcc/fortran/simplify.c:4138
4138              result_length = source_size / result_elt_size;

Here, source_size is correctly 8, but result_elt_size == 0 instead of 1
(character(len=1)).

The following fails at run time (nothing is printed):

program main
  implicit none
  character(len=8) :: t
  call test(t)
  print *, t
contains
  subroutine test(a)
    character(len=*) :: a
    a = transfer('Sample',a)
  end subroutine test
end program main


The following ill-defined program gives another ICE:
   compiler error: in gfc_interpret_character, at fortran/target-memory.c:360
(It is ill defined because the source size is smaller than the result size; cf.
PR 33037. NAG f95 prints "Intrinsic TRANSFER has partly undefined result")

program main
  implicit none
  character(len=8), target :: t
  character(len=8), pointer :: p
  p => t
  call test(p)
  print *, t
contains
  subroutine test(a)
    character(len=8),pointer :: a
    a = transfer('Sample',a)
  end subroutine test
end program main


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|ICE (FPE) for               |ICE or wrong code for
                   |TRANSFER('string', char_ptr)|TRANSFER of constant string
                   |                            |to character


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

Reply via email to