Hello,
when porting a ftn95 application from 32 bit to 64 bit we make use of C/CPP calls malloc and realloc. The following code may be used to compile/link a 32 bit and a 64 bit executable using Salford`s scc compiler. The 32 bit executable works ok, however, for the 64 bit executable the realloc call returns the null pointer, when it should not.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main() {
int chunk_size=16;
char* pChunk,*pChunk1;
pChunk=(char*)malloc(chunk_size);
printf('pChunk=0x%x\n',pChunk);
pChunk1=(char*)realloc(pChunk,chunk_size);
printf('pChunk1=0x%x\n',pChunk1);
strcpy(pChunk1,'123456781234567812345678');
printf('*pChunk1=%s\n',pChunk1);
return 0;
}
Output of 32 bit exe:
pChunk=0x3805970
pChunk1=0x3805958
*pChunk1=123456781234567812345678
Output of 64 bit exe:
pChunk=0x1d5bd0
pChunk1=0x0
A a consequence of realloc returning the NULL pointer the 64 bit executable crashes with an access violation.
Version information of scc: [Silverfrost SCC/WIN32 Ver 4.20 Copyright (c) Silverfrost Ltd 2018]
Regards, Dietmar