MOVE_ALLOC problems with 12.1.1

MOVE_ALLOC problems with 12.1.1

The following:

PROGRAM IFort12_1_being_a_PITA

  TYPE :: Parent
    INTEGER :: dummy
  END TYPE Parent
  TYPE :: Token
    INTEGER :: type
  END TYPE Token   
  CALL one_deep
  SUBROUTINE one_deep  
    !# Must be nested call.
    CALL two_deep                         
  SUBROUTINE two_deep
    !# Require this unused allocatable.
    TYPE(Token), ALLOCATABLE :: tlist(:)  
    CLASS(Parent), ALLOCATABLE :: ex  
    CALL Parse(ex)
    PRINT "('Ok')"
  END SUBROUTINE two_deep     !# Program explodes here.

  SUBROUTINE Parse(ex)
    !# Require this to not be polymorphic
    TYPE(Parent), ALLOCATABLE :: from
    CALL MOVE_ALLOC(from, ex)         
END PROGRAM IFort12_1_being_a_PITA

dies (unfairly IMHO) at runtime at the line indicated when compiled with 12.1.1 (update 7) on ia32 with /Od.

U:projectsifort 12.1 testmove-alloc>ifort /check:all /warn:all /standard-sema
ntics /traceback /Od ParsingTests.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 1 Build 20111011
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

ParsingTests.f90(22): remark #7712: This variable has not been used.   [TLIST]
    TYPE(Token), ALLOCATABLE :: tlist(:)
Microsoft  Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.


U:projectsifort 12.1 testmove-alloc>ParsingTests.exe
forrtl: severe (157): Program Exception - access violation
Image              PC        Routine            Line        Source
ParsingTests.exe   004058F5  Unknown               Unknown  Unknown
ParsingTests.exe   0040580C  Unknown               Unknown  Unknown
ParsingTests.exe   00401175  _IFORT12_1_BEING_          27  ParsingTests.f90
ParsingTests.exe   00401030  _IFORT12_1_BEING_          17  ParsingTests.f90
ParsingTests.exe   00401021  _MAIN__                    13  ParsingTests.f90
ParsingTests.exe   0044A5C3  Unknown               Unknown  Unknown
ParsingTests.exe   00430634  Unknown               Unknown  Unknown
kernel32.dll       7C817077  Unknown               Unknown  Unknown

This snippet extracted from a larger "test" program, which I'm pretty sure used to run successfully with pre 12.1 versions, but perhaps I was delusional, just lucky, or both.

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

FWIW, I compiled, linked and run your program with gfortran 4.6.2 and that gave no problems.



This may be of little value for explaining or pinpointing the error, but may be useful as a workaround:

Removing /Od and keeping your other options creates a program that runs with no errors.

Your example runs with the compiler with no errors.

I can reproduce the problem. The error occurs when the compiled code attempts to deallocate all local allocatable variables on exit from the routine - something has corrupted the memory manager's data or a descriptor for one of the variables. I can confirm that it does seem to work ok with Update 5 - my guess is that you really need /dbglibs to see the problem as this causes the C run-time library to add extra debugging support for memory allocations.

Retired 12/31/2016

Escalated as DPD200175822.

Retired 12/31/2016

Things seem to work ok if the type that is moved is polymorphic (CLASS(Parent) ... on line 32 rather than TYPE(Parent)). Is that a real workaround, or is the memory corruption or whatever just moved elsewhere?

My guess is that just moves the problem. It is highly dependent on memory layout.

Retired 12/31/2016

We have fixed this problem in the compiler sources - the fix will appear in a future version. The problem occurs when MOVE_ALLOC is used with the FROM being a non-polymorphic and the TO being polymorphic. If both FROM and TO are polymorphic, it's fine.

Retired 12/31/2016

Thanks - the both being polymorphic thing will be a handy workaround in the meantime, or I would have lots of wasted code.

Leave a Comment

Please sign in to add a comment. Not a member? Join today