Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

On default initialization

$
0
0

Hi,

Even though, in light of recent threads, the code is not useful, I was wondering: why, in the following code, the compiler reports missing initialization, when the field is already initialized?

module mod1

    type :: t1
        integer :: i = 0
    end type

    type :: t2
        type(t1) :: a
    end type

contains
    subroutine do_something()
        type(t2), allocatable :: t(:)

        allocate (t(1:0))
        t = [t, t2()]
    end subroutine

end module mod1

The definition of the type of the component is always available (as opposed to what might happen with the interface of a function or subroutine), so it could just check its initialization as well (and save the extra "= t1()" required in the declaration of the component). Or am I missing something obvious?

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



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