C assumes that pointers of the same type can point to the same location in memory (aliasing), and thus cannot perform certain optimizations.
For example, in the following program, the compiler is required to fetch
q point to the same memory as
p, it is invalid to reuse
p’s value fetched before
*q = 3 assignment.
int a, b, *p, *q; a = *p; *q = 3; b = *p;
The situation is made worse by C heavily relying on pointers.
On the other hand, Fortran simply didn’t have pointers. So it used to be faster than C. Fortran forbids aliasing and that’s programmer’s responsibility to ensure values do not alias. The compiler assumes values do not alias.
Recently, however aliasing analysis got much better so it can generate good code in most of the cases.
Fortran’s specialized for loop can generate faster code—another point that might have contributed to Fortran speed