Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28462 Discussions

Problem with default structure constructor when used in initialization expression

Harald
Beginner
388 Views
Hello,

the following code does not compile:

[fortran]program ifort_constructor
  implicit none
  type t
     type(t), pointer :: next(:) => NULL ()
  end type t
  type(t)            :: list  = t()     ! Accepted
  type(t), parameter :: empty = t()     ! Rejected
end program ifort_constructor
[/fortran]
% ifort -stand f03 -standard-semantics -warn all ifort_constructor.f90
ifort_constructor.f90(7): error #8212: Omitted field is not initialized. Field initialization missing: [NEXT]
type(t), parameter :: empty = t() ! Rejected
^
compilation aborted for ifort_constructor.f90 (code 1)


When replacing t() by t(NULL()) in the initialization for empty the code compiles.
Is there a reason why the default constructor does not work, or is it a bug?

0 Kudos
2 Replies
Steven_L_Intel1
Employee
388 Views
Bug. Escalated as DPD200176794. Thanks.
0 Kudos
Steven_L_Intel1
Employee
388 Views
This is fixed for a release later this year.
0 Kudos
Reply