This is a known problem but unfortunately there isn’t a good solution.
The problem stems from the fact that the Fortran malloc function is not an intrinsic function and thus is implicity defined to be “INTEGER4 malloc". Therefore, you must remember to explicitly declare "INTEGER8 malloc” or compile with “-i8” to be consistant with the size of the returned 64-bit pointer.
The second and more difficult problem is that the argument for malloc is INTEGER4 and is inconsistent with C’s 64-bit malloc. Ideally, we could simply port the Fortran malloc to 64-bits by changing the argument data type to INTEGER8. However, since integers are still implicity declared as INTEGER4, doing so would require all users to make sure the actual argument’s data type is INTEGER8. Since most users would probablly be unaware of this change, doing so would end up breaking a lot of code.
A second possible solution is create the INTEGER8 version of malloc and call it different name. Of course, the user would still need to explictiy declare it and make sure only INTEGER8 arguments are used, but we could then presume that the user understood these requirements.
While we don’t like to dictate how users code, the true solution to this problem is to not use malloc. Rather you should consider using Fortran 90’s allocatable arrays. Below, I’ve modified your code to use an allocatable array.
! pointer (iaa,b(:))
pointer :: b(:)
iasize = 1000000
! iaa = malloc(4*iasize)