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

Extending a TYPE and accessing character field causes compiler error

$
0
0

Greetings,

I am trying to learn how to extended types.  It appears that accessing a character range in a character array causes an issue compiling depending if the field is defined in the ancestor or in the child (see below).  Please let me know if I am doing something wrong, or if this is an compiler issue.  Using VS 2010 shell with IVFC XE 2013 (w_fcompxe_2013.1.119).

Thanks!

Program Inheritance

      Type S_ANCESTOR_PASS
        Character*2 Str(5)
      End Type

      Type, Extends (S_ANCESTOR_PASS) :: S_CHILD_PASS
      End Type S_CHILD_PASS

      Type S_ANCESTOR_FAIL
      End Type

      Type, Extends (S_ANCESTOR_FAIL) :: S_CHILD_FAIL
        Character*2 Str(5)
      End Type S_CHILD_FAIL

      Type (S_CHILD_PASS) :: Struct_Pass(5)
      Type (S_CHILD_FAIL) :: Struct_Fail(5)

      Struct_Pass(1).Str(1) = 'AB' !Compiles
      Struct_Fail(1).Str(1) = 'AB' !Compiles

      Struct_Pass(1).Str(1)(2:2) = 'C' !Compiles
      Struct_Fail(1).Str(1)(2:2) = 'C' !Does not compile, see below

      !Error 1: error #6460: This is not a field name that is defined in the encompassing structure.   [STR] Line 24
      !Error 2: error #6514: A substring must be of type CHARACTER.   [STR] Line 24
      !Error 3: error #6158: The structure-name is invalid or is missing.   [STRUCT_FAIL] Line 24

      End Program Inheritance

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



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