The information in this article applies to:
SUMMARYThe following is an example of a valid optimization that may take programmers by surprise.
MORE INFORMATIONFor example:
The compiler optimizes and eliminates the entire try-except statement
because temp is not used later.
If the value of temp were used globally, the compiler should treat the assignment to temp as volatile and do the assignment immediately even if it is overwritten later in the body of the try. The reasoning is that, at almost any point in the try body, control may jump to the except (or an exception filter). Presumably the programmer accessing the variable outside the try wants to get the current (most recently assigned) value. The way to prevent the compiler from performing the optimization is:
If a temporary variable is not needed, given the example, the read access
should still be specified as volatile, for example:
Additional query words: 3.10 3.50 4.00
Keywords : kbNTOS310 kbNTOS350 kbNTOS351 kbWinOS95 |
Last Reviewed: September 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |