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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-10 
10:35:22 UTC ---
Simplified program.

* As is, it prints 128
* Without  "txt", it prints 5 and segfaults
* Without  character(len=128) :: "txt",   it prints 5 and works

Thus, the extension to 128 characters does not properly work in the case of
having no character literal. That matches what is in the code:

          character(kind=1) A.16[2][1:5];
vs.
          character(kind=1) A.15[3][1:128];


I have not looked through the source code, but the first place, where
constructors string lengths are handled is array.c's
gfc_resolve_character_array_constructor. I don't quickly see whether it does so
correctly or not. If it does, the failure must be later.

It might be that in that function, the "txt" is correctly extended and padded
to len=128 - and that then everything is later handled correctly because the
first element has the right size?


program charArrErr
  implicit none
  call rou([character(len=128) :: "txt", uCase("abcde"),uCase("ghij_")])
contains
  subroutine rou(arr)
    implicit none
    character(*),intent(in) :: arr(:)
    print *, len(arr)
  end subroutine

  function uCase(str)
    implicit none
    character(*), intent(in) :: str
    character(len(str)) :: uCase
    uCase=str
  end function uCase
end program charArrErr

Reply via email to