This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
The following code (from http://home.comcast.net/~kmbtib/gfortran_bugs/REF_JVB_GFTN_005.html) fails in the following way (on i686-mingw and powerpc-apple-darwin): --------------------------------- module funcs implicit none contains function f(x) character(*), intent(in) :: x integer f(len(x)) integer i ! do i=1,len(x) ! f(i) = 0 ! end do end function f end module funcs program spec_expr_test use funcs implicit none write(*,*) size(f('test')) end program spec_expr_test --------------------------------- $ gfortran reduced_spec.f90 && ./a.out reduced_spec.f90: In function 'f': reduced_spec.f90:4: warning: Function does not return a value At line 19 of file reduced_spec.f90 Fortran runtime error: Internal: Possible double free of temporary. If you uncomment the three lines in the code above, you get a runtime segfault (on powerpc-apple-darwin): $ gfortran reduced_spec.f90 && ./a.out zsh: bus error ./a.out I don't know if these two issues are related, but I post them both in one PR just in case they can be debuggued altogether.
The segmentation fault seems to me to have the same source as PR19561 - temporaries are not being allocated/assigned properly. This does the first wriet OK and then seg faults on the second: ! { dg-do run } module funcs implicit none contains function f (x) character(*), intent(in) :: x integer f(len(x)) f = 0 end function f end module funcs program spec_expr_test use funcs implicit none integer, dimension(10) :: i i(1:5) = f ('test') write (*,*) i(1:5) write (*,*) f('untest') end program spec_expr_test ! { dg-error "Segmentation fault (core dumped)" }
Confirmed.
Fixed in 4.0.1.
Reopening for now, I think I read comment # 1 wrong.
the testcase in comment #1 no longer seg faults.
(In reply to comment #5) > the testcase in comment #1 no longer seg faults. module funcs implicit none contains function f(x) character(*), intent(in) :: x integer f(len(x)) integer i do i=1,len(x) f(i) = iachar (x(i:i)) end do end function f end module funcs program spec_expr_test use funcs implicit none write(*,*) f('test') end program spec_expr_test now compiles and runs correctly, as does my testcase. I will close this tonight
(In reply to comment #6) > I will close this tonight This never happened so I am closing it right now as fixed.