BUG: CodeView Executes Entire Single Statement LoopLast reviewed: May 1, 1996Article ID: Q85512 |
The information in this article applies to:
SYMPTOMSUnder certain circumstances CodeView will execute an entire for, while, or do-while loop containing a single line of source code. CodeView may appear to hang if the loop does many iterations, but that is not the case.
RESOLUTIONA detailed resolution follows. In the case of while and for loops, use braces in the loop body and do not have the closing brace on the same line as the single-line statement. In the case of do-while loops, do not have the while on the same line as the single-line statement.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe following forms of for, while, and do-while loops execute completely while trying to single step under CodeView:
for( initialize ; test ; action ) statement1, statement2, ..., statementn; for( initialize ; test ; action ) { statement1, statement2, ..., statementn; } for( initialize ; test ; action ) { statement1, statement2, ..., statementn; } for( initialize ; test ; action ) { statement1, statement2, ..., statementn; } while( condition ) statement1, statement2, ..., statementn; while( condition ) { statement1, statement2, ..., statementn; } while( condition ) { statement1, statement2, ..., statementn; } while( condition ) { statement1, statement2, ..., statementn; } do statement1, statement2, ..., statementn; while( condition ); do statement1, statement2, ..., statementn; while( condition ); do { statement1, statement2, ..., statementn; } while( condition ); do { statement1, statement2, ..., statementn; } while( condition );The following forms of for, while, and do-while loops execute as expected when single stepping under CodeView:
for( initialize ; test ; action ) { statement1, statement2, ..., statementn; } for( initialize ; test ; action ) { statement1, statement2, ..., statementn; } while( condition ) { statement1, statement2, ..., statementn; } while( condition ) { statement1, statement2, ..., statementn; } do statement1, statement2, ..., statementn; while( condition ); do statement1, statement2, ..., statementn; while( condition ); do { statement1, statement2, ..., statementn; } while( condition ); do { statement1, statement2, ..., statementn; } while( condition );The for, while, and do-while loops also execute correctly if multiple statement lines are broken up into separate lines. The following source code appears to hang when tracing into or stepping over with CodeView. The following code does not demonstrate every case, but the behavior is the same for all of the cases above.
Sample Code
/* Compile options needed: /Zi /Od */ #define SIZE 500 int array[SIZE]; int main(void){ int index = 0, flag = 0; for( index = 0; index < SIZE ; index++) array[index] = index; /* CodeView appears to hang here. Wait and the loop will execute completely. */ index = 0; while( index < SIZE ) array[index] = index, flag = index++; /* CodeView appears to hang here. Wait and the loop will execute completely. */ return ( 1 );}
|
Additional reference words: 3.00 3.50 4.00 4.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |