Software Archive
Read-only legacy content
17060 Discussions

Dynamic memory allocation in Fortran DLL

ikawa
Beginner
225 Views
The following code:

pointer (iaa,a(1))
call free(iaa)
iaa = malloc(4*2*8066907)

do ii = 1, 7566907
a(ii) = 0
enddo

works fine as a part of a Fortran exe program but it
generates an error as part of a Fortran DLL
for a(ii) = 0 when ii=2

Unhandled exception in Prog1.exe (TESTSUB.DLL):
0xC000008C: Array Bounds Exceeded.

What I can do to run this piece of code inside a Fortran DLL
file without any errors?

TIA,

Izydor
0 Kudos
3 Replies
Steven_L_Intel1
Employee
225 Views
Change a(1) to a(*)

Incidentally, you'd get the same error in an executable program if compiled with bounds checking enabled.

Steve
0 Kudos
Intel_C_Intel
Employee
225 Views
Isn't it bad form to call free before malloc?
0 Kudos
Steven_L_Intel1
Employee
225 Views
Indeed it is!

Steve
0 Kudos
Reply