While IPA's interprocedural optimizations can significantly
improve performance of a program, they can also cause previously incorrect
but functioning programs to fail. Some programming practices that can work
by accident without aggressive optimization but are exposed with IPA include:
- Relying on the allocation order or location of automatic variables, such
as taking the address of an automatic variable and then later comparing it
with the address of another local variable to determine the growth direction
of a stack. The C language does not guarantee where an automatic variable
is allocated, or its position relative to other automatic variables. Do not
compile such a function with IPA.
- Accessing a pointer that is either invalid or beyond an array's bounds.
Because IPA can reorganize global data structures, a wayward pointer which
might have previously modified unused memory might now trample upon user-allocated
storage.