H-Series Application Migration Guide (H06.03+)

General Programming Issues
H-Series Application Migration Guide429855-006
4-5
Optimizing on TNS/E Might Expose Errors
Optimizing on TNS/E Might Expose Errors
The optimizers for the TNS/E C/C++ and pTAL compilers perform significantly more
optimizations that do the TNS/R optimizers. As a result, programs that contain
programming errors but still run correctly when compiled at optimization level 2 on a
TNS/R system might not run correctly when compiled at optimization level 2 on a
TNS/E system. If this situation occurs, there are some steps you can take to determine
the cause of the error. If you are unable trace the problem to a programming error, you
may request assistance from HP, but you must include certain important details in your
request.
Possible Programming Errors
If a program runs correctly when compiled at optimization level 0 but produces errors
at levels 1 or 2, possible causes include:
The program does not conform to the language standards. Either the code violates
the compiler’s assumptions or a compiler directive is used incorrectly.
The program references uninitialized variables during execution. Without
optimization, variables are often “accidentally” initialized with a zero value, but this
is less likely with optimization.
Physical dependencies have changed with optimization. For example, a program
that relies on timing dependencies might fail because an idle wait loop takes less
time per iteration.
Optimization has changed memory access patterns. This can result in different
page fault or cache miss effects.
Variables residing in shared memory are not made known to the compiler (for
example, by using the volatile type specifier). This can result in invalid
optimizations.
Improper use of inlining. Inlining occurs at levels 1 and 2, but not at level 0. A
program must be careful in the prototypes it includes and the functions it marks as
inline when it expects the address of the functions to be available.
Once you have eliminated these possible causes, consider reporting the problem to
HP. But first:
Check to make sure that the program runs correctly at a lower level of optimization.
Make sure that there were no source code or build step changes in either your
program or in programs on which you depend.
If you decide to report the problem to HP, you need to provide certain information in
your report. For details on what to include in your problem report, see Appendix C,
Reporting Compiler Optimization Problems.