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

One more structure constructor error

Sean_S_2
Beginner
1,008 Views

If you try to use a structure constructor to construct a type that extends from some other type, and you have an array section argument, you get an error like the following:

test_section_constructor.F90(18): error #6593: The number of expressions in a structure constructor differs from the number of components of the derived type   [FOO]
b = foo(a2(:,1)) ! Spurious error
----^
compilation aborted for test_section_constructor.F90 (code 1)

This happens even when you only have one component and one argument to the structure constructor.

Here's the full test case:

program test_section_constructor

implicit none

type, abstract :: foo_base
end type foo_base

type, extends(foo_base) :: foo
   integer, allocatable :: a(:)
end type foo

type(foo) :: b

integer :: a1(2) = 0
integer :: a2(2,2) = 0

b = foo(a1)      ! OK
b = foo(a2(:,1)) ! Spurious error

end program test_section_constructor

 

0 Kudos
4 Replies
Kevin_D_Intel
Employee
1,008 Views

I reproduced this error and forwarded to Development (under internal tracking id below) and will update the post regarding a fix.

(Internal tracking id: DPD200255191)

0 Kudos
Sean_S_2
Beginner
1,008 Views

I've found that this also occurs with certain intrinsics as the argument, e.g. "spread".

0 Kudos
Kevin_D_Intel
Employee
1,008 Views

Ok, thank you for the new info. I added a note to the Developers regarding that.

0 Kudos
Sean_S_2
Beginner
1,008 Views

It seems that this was addressed in 15.0.0

0 Kudos
Reply