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

Using structure constructor for empty type as actual argument

$
0
0

If a structure constructor for an empty extension type is used as an actual argument to an polymorphic INTENT(IN) dummy of the parent type, then strange things happen.

MODULE m
  IMPLICIT NONE

  TYPE, PUBLIC :: EmptyType
!    INTEGER :: dummy = 0   ! <<<<
  CONTAINS
    PROCEDURE, NOPASS :: XYZ => True
  END TYPE EmptyType
CONTAINS
  FUNCTION True() RESULT(b)
    LOGICAL :: b
    b = .TRUE.
  END FUNCTION True

  FUNCTION False() RESULT(b)
    LOGICAL :: b
    b = .FALSE.
  END FUNCTION False

  SUBROUTINE Proc(arg)
    CLASS(EmptyType), INTENT(IN) :: arg

    PRINT *, arg%XYZ()
  END SUBROUTINE Proc
END MODULE m

PROGRAM p
  USE m
  IMPLICIT NONE

  TYPE, EXTENDS(EmptyType) :: extension
  CONTAINS
    PROCEDURE, NOPASS :: XYZ => False
  END TYPE extension

  CALL Proc(extension())
END PROGRAM p

 

>ifort /check:all /warn:all /standard-semantics /traceback "2015-09-07 Empty.f90"&& "2015-09-07 Empty.exe"
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

"-out:2015-09-07 Empty.exe"
-subsystem:console
-incremental:no"2015-09-07 Empty.obj"
forrtl: severe (408): fort: (7): Attempt to use pointer ARG when it is not associated with a target

Image              PC                Routine            Line        Source
2015-09-07 Empty.  000000013FAD3BCE  Unknown               Unknown  Unknown
2015-09-07 Empty.  000000013FAD1173  M_mp_PROC                  23  2015-09-07 Empty.f90
2015-09-07 Empty.  000000013FAD12FE  MAIN__                     36  2015-09-07 Empty.f90
2015-09-07 Empty.  000000013FB2362E  Unknown               Unknown  Unknown
2015-09-07 Empty.  000000013FB104C3  Unknown               Unknown  Unknown
kernel32.dll       00000000771559CD  Unknown               Unknown  Unknown
ntdll.dll          000000007738B981  Unknown               Unknown  Unknown

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles