PRB:C/QC May Incorrectly Parse Consecutive Blocks with _asm

ID Number: Q72227

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax fixlist7.00

Summary:

SYMPTOMS

Microsoft C versions 6.0, 6.0a, and 6.0ax and QuickC versions

2.0, 2.01, 2.5, and 2.51 may incorrectly parse consecutive blocks

of code that contain inline assembly when all of the following

conditions are met:

- A block of code in the source file contains inline assembly.

- The entire block, including opening and closing curly braces,

is placed on a single logical line.

- There is an inline assembly block following the code block with

the embedded inline assembly described above.

When the sample code below is compiled, it is parsed incorrectly

and the following incorrect errors are generated:

error C2065: 'popf' : undefined

error C2143: syntax error : missing ';' before '}'

error C2059: syntax error : '}'

CAUSE

With these conditions, the first inline assembly instructions will

be considered undefined and there may be syntax errors on some or

all of the closing curly braces that follow.

RESOLUTION

These errors may be eliminated by using either of the following two

workarounds:

- Make sure that the braces for the first block are not on the

same logical line. For example, in the sample code below, the

line

{ x = 2; _asm pushf }

could be changed to the following:

{ x = 2;

_asm pushf

}

-or-

- Remove the braces from the first block.

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax and QuickC versions 2.0, 2.01, 2.5, and 2.51

(buglist2.00, buglist2.01, buglist2.50, and buglist2.51). This

problem was corrected in C version 7.0.

More Information:

Sample Code

-----------

/* Compile options needed: none

*/

void test( )

{

int x;

{ x = 2; _asm pushf }

_asm

{

popf

}

}

Additional reference words: 2.00 2.50 6.00 6.00a 6.00ax