Quantcast
Viewing all articles
Browse latest Browse all 3270

One more structure constructor error

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

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>