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