Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Parameterized Derived Types: a question on structure constructors for types with default values of parameters

$
0
0

Consider the following simple code involving a parameterized derived type (PDT):

program p

   implicit none

   type :: t(k)
      integer, kind :: k = 0
   end type

   !type(t) :: foo = t(k=0)()    ! <-- This works

   type(t) :: foo = t()          ! <-- This does not

   print *, "foo%k = ", foo%k

   stop

end program p
Compiling with Intel(R) Visual Fortran Compiler 17.0.0.109 [Intel(R) 64]...
p.f90
p.f90(11): error #6197: An assignment of different structure types is invalid.   [FOO]
ifort: error #10298: problem during post processing of parallel object compilation
compilation aborted for p.f90 (code 1)

It would appear Intel Fortran development team's interpretation of the standard is type parameters must be declared with the type in a structure constructor - is this correct?  It does not seem right, but I could be wrong yet I couldn't find any supporting statement(s) or constraint(s) in the standard document (WD 1539-1 J3/10-007r1 for Fortran 2008, 24 Nov. 2010) in favor of Intel Fortran implementation.  All I find in relation to structure constructors points back to "derived-type-spec" which has the following: see the highlighted line 31 (i.e., point 4.5.9.3)

 

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



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