- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code is valid but yields a segmentation fault with IFX 2025.2.
module con_mod
type :: con_type
integer, allocatable :: val
end type
interface con_type
module procedure :: con_maker
end interface
contains
pure elemental function isequal(con, value) result(itis)
type(con_type), intent(in) :: con, value
logical :: itis
itis = con%val == value%val
end function
pure elemental function con_maker(val) result(con)
!pure function con_maker(val) result(con)
integer, intent(in) :: val
type(con_type) :: con
con%val = val
end function
end module con_mod
use con_mod, only: con_type, isequal
implicit none
type(con_type), allocatable :: values(:)
values = [con_type(1), con_type(2)]
print *, isequal(con_type(1), values)
end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's unbelievable how many times over the past week I tried to post this error here, but I was tagged as s--p--a--m immediately. I had to cut extensive information surrounding this error to allow its posting here. I do not know what triggers the s*** detector of this forum, but one thing is for sure: This forum currently has a terrible automated s*** detector.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Back to the problem, the issue lies in the elemental attribute of the derived type constructor. If you remove it, the segmentation fault error in the function iequal() will be resolved. This error does not occur with ifort or gfortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
module con_mod
type :: con_type
integer, allocatable :: val
end type
interface con_type
module procedure :: con_maker
end interface
contains
pure elemental function isequal(con, value) result(itis)
type(con_type), intent(in) :: con, value
logical :: itis
itis = con%val == value%val
end function
pure elemental function con_maker(val) result(con)
!pure function con_maker(val) result(con)
integer, intent(in) :: val
type(con_type) :: con
con%val = val
end function
end module con_mod
use con_mod, only: con_type, isequal
implicit none
type(con_type), allocatable :: values(:)
values = [con_type(1), con_type(2)]
print *, isequal(con_type(1), values)
end
It is way easier to read if you use the insert code </> button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Blame the automatic spam detector of this forum for the lack of format!

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