http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47042
Summary: ICE with character pointer in function
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: [email protected]
ReportedBy: [email protected]
I am not sure this is valid code, but it gives and ICE. There is no ICE if the
ptmp pointer is removed or the function is compiled outside the program block.
program bug
contains
function get_cstring (c_str, maxlen, c_term_char)
use iso_c_binding, only: c_ptr, c_char, c_null_char
character(kind=c_char, len=maxlen) :: get_cstring
character(kind=c_char,len=1), optional :: c_term_char
character(kind=c_char), pointer :: ptmp
type(c_ptr) :: c_str
integer :: i, maxlen
call c_f_pointer (c_str, ptmp)
do i=1,maxlen
get_cstring(i:i) = ptmp(i)
if (ptmp(i) == c_null_char) goto 10
if (present(c_term_char).and.ptmp(i) == c_term_char) goto 10
end do
return
10 continue
end function
end program