- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code compiles with ifort12.1.0 20110811 and gfortran4.6.1 20110422 without any warnings. Yet the results produced by programs compiled with respective compilers differ.
[fortran]module class_a type :: a real, pointer :: t => null() real :: p = 11. end type a end module class_a module class_a_extended use class_a type, extends(a) :: a_extended end type a_extended end module class_a_extended module class_b use class_a type :: b class(a), pointer :: ap end type b end module class_b program inheritance_test use class_a_extended use class_b type(a_extended), target :: a_extended_type class(b), pointer :: b_class type(b) :: b_type allocate(a_extended_type % t) allocate(b_class) a_extended_type % t = 888. b_class % ap => a_extended_type % a b_type % ap => a_extended_type % a ! this does not work print *, a_extended_type % t print *, b_class % ap % t print *, b_type % ap % t ! this works just fine print *, a_extended_type % p print *, b_class % ap % p print *, b_type % ap % p end program inheritance_test [/fortran]
gfortran compiled code yields:
888.00000
888.00000
888.00000
11.000000
11.000000
11.000000
while ifort compiled code prints:
888.0000
1.8362133E-33
888.0000
11.00000
11.00000
11.00000
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It starts to work with ifort when
[fortran]class(a), pointer :: ap[/fortran]is changed to
[fortran]type(a), pointer :: ap [/fortran]
in a definition of type b
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - we'll take a look.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page