Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 19574
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 19574 depends on: Show dependency tree
Show dependency graph
Bug 19574 blocks: 19766

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-05-04 02:06 Opened: 2005-01-22 11:47
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.

------- Comment #1 From Paul Thomas 2005-01-25 10:57 -------
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)" }

------- Comment #2 From Andrew Pinski 2005-02-02 19:20 -------
Confirmed.

------- Comment #3 From Andrew Pinski 2005-06-06 00:33 -------
Fixed in 4.0.1.

------- Comment #4 From Andrew Pinski 2005-06-06 00:33 -------
Reopening for now, I think I read comment # 1 wrong.

------- Comment #5 From Andrew Pinski 2005-09-18 05:42 -------
the testcase in comment #1 no longer seg faults.

------- Comment #6 From Paul Thomas 2005-12-15 14:49 -------
(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

------- Comment #7 From Andrew Pinski 2006-01-02 07:16 -------
(In reply to comment #6)
> I will close this tonight

This never happened so I am closing it right now as fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug