#581: Pass unallocated arrays to Fortran as NULL pointers --------------------------+------------------------------------------------- Reporter: eschnett | Owner: Type: enhancement | Status: review Priority: major | Milestone: Component: Cactus | Version: Resolution: | Keywords: --------------------------+-------------------------------------------------
Comment (by rhaas):
while I think I can definitely construct a situation where a compiler is perfectly correct in trying to access the NULL pointer, namely something like:
{{{ CCTK_REAL gxx(cctk_lsh(1), cctk_lsh(2), cctk_lsh(3)) CCTK_REAL betax(cctk_lsh(1), cctk_lsh(2), cctk_lsh(3)) ... gxxL = gxx(i,j,k) if(shift_state.ne.0) then bx = betax(i,j,k) else bx = 0.0 endif }}}
I think that unless we actually know of a compiler that gives segfaults in this case I would think that the benefit of having unallocated grid functions detected in Fortran outweights the undocumented behaviour we exploit here (plus we are already using undocumented/compiler-specific features when calling Fortran code from C).
I compiles for me and seems to not crash the testsuites (gcc 4.6). Please apply.