- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I'm somewhat confused by the following code:
module mod1
implicit none
private
type, abstract, public :: required
contains
procedure(i_proc1), deferred, pass(this) :: proc1
procedure(i_proc2), deferred :: proc2
end type
abstract interface
pure subroutine i_proc1(data, string, this)
import
class(*), intent(inout) :: data
character(*), intent(in) :: string
class(required), intent(inout) :: this
end subroutine
pure subroutine i_proc2(this, string, DATA)
import
class(required), intent(in) :: this
character(:), allocatable, intent(inout) :: string
class(*), optional, intent(in) :: DATA
end subroutine
end interface
public :: i_proc1
public :: i_proc2
end module mod1
module mod2
use mod1
implicit none
private
type, extends(required), public :: child
! type, public :: child
integer :: offset = 0
logical :: valid = .false.
contains
procedure, pass(this) :: proc1 => child_proc1
procedure :: proc2 => child_proc2
end type
interface
module pure subroutine child_proc1(data, string, this)
class(*), intent(inout) :: data
character(*), intent(in) :: string
class(child), intent(inout) :: this
end subroutine
module pure subroutine child_proc2(this, string, DATA)
class(child), intent(in) :: this
character(:), allocatable, intent(inout) :: string
class(*), optional, intent(in) :: DATA
end subroutine
end interface
type, extends(required), public :: parent
! type, public :: parent
character(:), allocatable :: name
type(child) :: ch
contains
procedure, pass(this) :: proc1 => parent_proc1
procedure :: proc2 => parent_proc2
end type
interface
module pure subroutine parent_proc1(data, string, this)
class(*), intent(inout) :: data
character(*), intent(in) :: string
class(parent), intent(inout) :: this
end subroutine
module pure subroutine parent_proc2(this, string, DATA)
class(parent), intent(in) :: this
character(:), allocatable, intent(inout) :: string
class(*), optional, intent(in) :: DATA
end subroutine
end interface
contains
function default_parent() result(p)
type(parent) :: p
p = parent(name = 'default')
end function
end module mod2
If I compile it, i get:
ifx -V -c /media/vmshare/implements-constructor.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2025.0.4 Build 20241205
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
Intel(R) Fortran 25.0-1205.1
/media/vmshare/implements-constructor.f90(83): error #7316: Null components (probably caused by extra commas) in a structure constructor are invalid. [CHILD]
p = parent(name = 'default')
^
With flang-new (19.x), I get a similar error (that the constructor lacks a value for "ch"). But gfortran (14.x) compiles the code without issue.
As I see it, the child derived type already has full default initialization, so nothing should be required.
Am I correct or is the code invalid?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jwmwalrus sorry for the delay. I don't mind the bump. I believe Steve is on vacation. I will ask our Standards guru about this one. It looks valid to me as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We think it's valid code. And a bug in our compiler. I have a bug report started, but I need to wait to submit it next week. We have a number of our servers offline until Monday. I need those up before I can finalize the report. Once that is done I will have a bug ID to post here.

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