Parallel Programming Guide for HP-UX Systems

Troubleshooting
Aliasing
Chapter 9 169
Aliasing
An alias is an alternate name for an object. Fortran EQUIVALENCE
statements, C pointers, and procedure calls in both languages can
potentially cause aliasing problems. Problems can and do occur at
optimization levels +O3 and above. However, code motion can also cause
aliasing problems at optimization levels +O1 and above.
Because they frequently use pointers, C programs are especially
susceptible to aliasing problems. By default, the optimizer assumes that
a pointer can point to any object in the entire application. Thus, any two
pointers are potential aliases. The C compiler has two algorithms you
can specify in place of the default: an ANSI-C aliasing algorithm and a
type-safe algorithm.
The ANSI-C algorithm is enabled [disabled] through the
+O[no]ptrs_ansi option.
The type-safe algorithm is enabled [disabled] by specifying the
command-line option +O[no]ptrs_strongly_typed.
The defaults for these options are +Onoptrs_ansi and
+Onoptrs_strongly_typed.
ANSI algorithm
ANSI C provides strict type-checking. Pointers and variables cannot
alias with pointers or variables of a different base type. The ANSI C
aliasing algorithm may not be safe if your program is not ANSI
compliant.
Type-safe algorithm
The type-safe algorithm provides stricter type-checking. This allows the
C compiler to use a stricter algorithm that eliminates many potential
aliases found by the ANSI algorithm.
Specifying aliasing modes
To specify an aliasing mode, use one of the following options on the C
compiler command line: