There are two alternatives for optimization with pointers.
Do not use pointers with optimization level -O4.
Use a pointer only to identify the location of the data for calculations and pass the pointer to a subprogram. Almost anything else you do to the pointer can yield incorrect results.
The second choice also has a suboption: localize pointers to one routine and do not optimize it, but do optimize the routines that do the calculations. If you put the calling the routines on different files, you can optimize one and not optimize the other.
REAL A, B, V(100,100) This programming unit does POINTER ( P, V ) nothing else with P other than P = MALLOC(10000) getting the address and passing it. ... CALL CALC ( P, A ) ... END SUBROUTINE CALC ( ARRAY, X ) ... RETURN END
If you want to optimize only CALC at level -O4, then avoid using pointers in CALC.