- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Here is an example of what causes a segmentation fault in my F2003 code :
[fortran]module m
implicit none
! Type definition
type :: my_type
real, allocatable, dimension(:) :: Tab ! Allocatable array (LINE 1)
real :: T ! Followed by something else (LINE 2)
contains
generic :: init => init1, init2 ! With a generic method (LINE 3)
procedure :: init1
procedure :: init2
end type
contains
!------------------------------------
subroutine init1(self)
class(my_type) :: self
end subroutine init1
!------------------------------------
subroutine init2(self, n)
class(my_type) :: self
integer :: n
end subroutine init2
!------------------------------------
end module m
program test
use m
implicit none
type(my_type) :: a, b
! Fill first object
a%T = 2.0
allocate(a%Tab(10))
a%Tab(:) = 0.0
! assignment of 2nd object
b = a ! This causes segmentation fault
end program test[/fortran] Commenting "LINE 1", "LINE 2" or "LINE 3" and the corresponding line in the program where values are given to components of object 'a' makes the segmentation fault disappear. The combination of allocatable component and generic binding then seems to be the reason.
I compiled with the option '-assumerealloc_lhs' or '-standard-semantics' but this did not fix it.
My compilier version is :
ifort (IFORT) 12.1.0 20110811
Thanks.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This looks familiar - I think it's a bug we have fixed for a release in September. I will check when I get into the office on Monday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this works in the September release version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I'll make sure to check out this version when it is released.
In the meantime, I found out that putting allocatable components at the end of the derived type declaration enables to avoid the bug.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page