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

Deferred length character component in abstract derived type causes grief

IanH
Honored Contributor III
449 Views
The code used to previously demonstrate a somewhat obscure optimiser problem here (which got fixed - thanks) now demonstrates a somewhat less obscure issue with the subject line under 12.1.0 that wasn't in previous versions. The code can be simplified down to:

[fortran]MODULE ContainerObjects
  IMPLICIT NONE
  PRIVATE
  
  TYPE, PUBLIC, ABSTRACT :: Cont
    CHARACTER(:), ALLOCATABLE :: name
  CONTAINS
    PROCEDURE(init_intf), DEFERRED :: Init
  END TYPE Cont
  
  TYPE, PUBLIC, EXTENDS(Cont) :: ContB
    REAL :: r
  CONTAINS
    PROCEDURE :: Init => scb_Init
  END TYPE ContB
  
  ABSTRACT INTERFACE
    SUBROUTINE init_intf(s)
      IMPORT Cont
      IMPLICIT NONE
      CLASS(Cont), INTENT(OUT) :: s
    END SUBROUTINE init_intf
  END INTERFACE
CONTAINS  
  SUBROUTINE scb_Init(s)
    CLASS(ContB), INTENT(OUT) :: s
    s%r = 1.0                            ! Boom.
  END SUBROUTINE scb_Init
END MODULE ContainerObjects


PROGRAM PolyAlloc
  USE ContainerObjects
  IMPLICIT NONE
  CLASS(Cont), ALLOCATABLE :: s1
  !****
  ALLOCATE(ContB:: s1)
  CALL s1%Init
END PROGRAM PolyAlloc
[/fortran]

[plain]>ifort /check:all /warn:all /standard-semantics /traceback /Od /debug:full poly-alloc.f90 && poly-alloc.exe
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.0.233 Build 20110811
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

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

-out:poly-alloc.exe
-debug
-pdb:poly-alloc.pdb
-subsystem:console
-incremental:no
poly-alloc.obj
forrtl: severe (157): Program Exception - access violation
Image              PC        Routine            Line        Source
poly-alloc.exe     0040106B  _CONTAINEROBJECTS          28  poly-alloc.f90
poly-alloc.exe     00401265  _MAIN__                    39  poly-alloc.f90
poly-alloc.exe     00476193  Unknown               Unknown  Unknown
poly-alloc.exe     0044D555  Unknown               Unknown  Unknown
kernel32.dll       7C817077  Unknown               Unknown  Unknown[/plain]


0 Kudos
1 Reply
Steven_L_Intel1
Employee
449 Views
I'll take a look.
0 Kudos
Reply