Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Optional polymorphic arguments

IanH
Honored Contributor III
686 Views
Optional arguments that are also polymorphic seem to have runtime issues. The following inocuous example:
[fortran]MODULE MyChickenIsARooster
  IMPLICIT NONE
  TYPE :: Parent
    INTEGER :: i
  END TYPE Parent
CONTAINS
  SUBROUTINE Level1(arg)
    CLASS(Parent), INTENT(IN), OPTIONAL :: arg
    CALL Level2(ARG=arg)
  END SUBROUTINE Level1

  SUBROUTINE Level2(arg)
    CLASS(Parent), INTENT(IN), OPTIONAL :: arg
    IF (PRESENT(arg)) THEN
      PRINT *, 'Hello play :)'
    ELSE
      PRINT *, 'Hello work :('
    END IF
  END SUBROUTINE Level2
END MODULE MyChickenIsARooster

PROGRAM OptionallyPolymorphic
  USE MyChickenIsARooster
  IMPLICIT NONE
  CALL Level1
END PROGRAM OptionallyPolymorphic
[/fortran]
compiles ok, but explodes on execution:

[plain]>ifort /check:all /warn:all /standard-semantics /stand:f03 /traceback /debug optionally_polymorphic.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

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

-out:optionally_polymorphic.exe
-debug
-pdb:optionally_polymorphic.pdb
-subsystem:console
-incremental:no
optionally_polymorphic.obj

>optionally_polymorphic
forrtl: severe (157): Program Exception - access violation
Image              PC        Routine            Line        Source
optionally_polymo  00401006  _MYCHICKENISAROOS           9  optionally_polymorphic.f90
optionally_polymo  0040113B  _MAIN__                    25  optionally_polymorphic.f90
optionally_polymo  004786F3  Unknown               Unknown  Unknown
optionally_polymo  0044DF0B  Unknown               Unknown  Unknown
kernel32.dll       7C817077  Unknown               Unknown  Unknown[/plain]
0 Kudos
4 Replies
mecej4
Honored Contributor III
686 Views
Works without /check:all. Often, especially with sources that use bleeding edge language features, the /warn and /check options are unable to keep up.
0 Kudos
Steven_L_Intel1
Employee
686 Views
Seems to be /check:pointer that is the culprit here. I will let the developers know - thanks. Issue ID is DPD200170041.
0 Kudos
Steven_L_Intel1
Employee
686 Views
This has been fixed for an update later this year.
0 Kudos
Steven_L_Intel1
Employee
686 Views
This is fixed in Update 7.
0 Kudos
Reply