X hits on this document

1022 views

0 shares

0 downloads

0 comments

102 / 396

Chapter ‎18   Unsafe code

Otherwise, v is considered not definitely assigned on the control flow transfer to either the then-stmt or else-stmt, or to the end-point of stmt if there is no else clause.

5.3.3.6 Switch statements

In a switch statement stmt with a controlling expression expr:

The definite assignment state of v at the beginning of expr is the same as the state of v at the beginning of stmt.

The definite assignment state of v on the control flow transfer to a reachable switch block statement list is the same as the definite assignment state of v at the end of expr.

5.3.3.7 While statements

For a while statement stmt of the form:

while ( expr ) while-body

v has the same definite assignment state at the beginning of expr as at the beginning of stmt.

If v is definitely assigned at the end of expr, then it is definitely assigned on the control flow transfer to while-body and to the end point of stmt.

If v has the state “definitely assigned after true expression” at the end of expr, then it is definitely assigned on the control flow transfer to while-body, but not definitely assigned at the end-point of stmt.

If v has the state “definitely assigned after false expression” at the end of expr, then it is definitely assigned on the control flow transfer to the end point of stmt, but not definitely assigned on the control flow transfer to while-body.

5.3.3.8 Do statements

For a do statement stmt of the form:

do do-body while ( expr ) ;

v has the same definite assignment state on the control flow transfer from the beginning of stmt to do-body as at the beginning of stmt.

v has the same definite assignment state at the beginning of expr as at the end point of do-body.

If v is definitely assigned at the end of expr, then it is definitely assigned on the control flow transfer to the end point of stmt.

If v has the state “definitely assigned after false expression” at the end of expr, then it is definitely assigned on the control flow transfer to the end point of stmt.

5.3.3.9 For statements

Definite assignment checking for a for statement of the form:

for ( for-initializer ; for-condition ; for-iterator ) embedded-statement

is done as if the statement were written:

{ for-initializer ; while ( for-condition ) { embedded-statement ; for-iterator ; } }

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.89

Document info
Document views1022
Page views1022
Page last viewedFri Dec 09 22:48:09 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments