FIX: Incorrect Optimization of Left Shift OperatorLast reviewed: September 18, 1997Article ID: Q113427 |
1.00
WINDOWS NT
kbtool kbfixlist kbbuglist
The information in this article applies to:
SYMPTOMSOptimization of the left shift operator may generate incorrect code in loop operations when compiled with global optimizations on. In the code sample below, the "for" loop incorrectly evaluates the "count" variable. The resultant code causes the loop to execute only once with the following output:
0 RESOLUTIONTurn off global optimizations (/Og). In the code sample below, turning off global optimizations will correctly output:
0 40000000 80000000 C0000000Global optimizations can be disabled by excluding /Og from the command-line switches or by the use of a pragma:
#pragma optimize ("g", off) STATUSMicrosoft has confirmed this to be a problem in the Microsoft C/C++ 32-bit compiler, version 8.0, which is included with Visual C++ 32-bit Edition. This problem was corrected in C/C++ compiler version 9.0, included with Visual C++ 32-bit Edition, version 2.0
Sample Code
/** Compile options needed: /Og */ #include <stdio.h> void main( void ){ unsigned count; for ( count = 0 ; count < 4 ; count++ ) printf(" %X \n", count << 30); } |
Additional reference words: 1.00 8.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |