Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Failed deallocation for alloc. return value

$
0
0

Hi,

i got a Problem with the deallocation of an allocatable character return value between a dll and the executable. After the assignment completes the exe trys to deallocate the return-value of the foo-function, wich fails.

Debug Error Message: "Damage before <Address of BAR> which was allocated by aligned routine"

Code of the dll:

! Compiler Options:
!   No influence on failure:
!     /Qfp-stack-check /Od /traceback /warn:all /debug:full
!   Those are influencing the issue:
!     /MTd /Qopenmp
module TEST_MODULE
  implicit none
contains

  function foo() result(bar)
    !DEC$ ATTRIBUTES DLLEXPORT,ALIAS:"TEST_MODULE_test" :: foo
    character(:), allocatable :: bar
    bar = 'Wiesel'
    write(*,'("0x",Z8.8)') loc(bar)
  end function

end module TEST_MODULE
Code of the exe:

! Compiler Options:
!   No influence on failure:
!     /Od /traceback /debug:full
!   Those are influencing the issue:
!     /MTd (/Qopenmp)
program main
  use TEST_MODULE
  implicit none

  character(:), allocatable :: a_char
  a_char = foo()

end program

 

It works, when both Targets are using /Qopenmp, or only the exe.
It also works, if /MD(d) is used for both (did not try to mix it).

The Problem occured with Compiler 17 and 17 Update 1. It works with Compiler 16 U3 and U4.

Visual Studio 2015 / Windows 10

Greetings

Wolf


Viewing all articles
Browse latest Browse all 415


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>