Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Dynamic memory allocation in Fortran DLL

ikawa
Beginner
464 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
464 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
464 Views
Isn't it bad form to call free before malloc?
0 Kudos
Steven_L_Intel1
Employee
464 Views
Indeed it is!

Steve
0 Kudos
Reply