Compiler Incorrectly Generates 80186+ Code

ID Number: Q66697

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

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

Summary:

SYMPTOMS

The sample code below incorrectly generates the instruction "shl bx,

2" for 8086/8088 machines when compiled for large or compact memory

model (/AL or /AC) with C version 6.0, 6.0a, or 6.0ax. When using

an 8086/8088 machine, the only valid second operands are cl and 1.

The ability to use an immediate value other than 1 was not available

until the 80186.

STATUS

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

6.0a, and 6.0ax. This problem was corrected in C/C++ version 7.0.

More Information:

Sample Code

-----------

/* Compile options needed: /AL or /AC

*/

extern int f2 (double *,double *, double *, double *,

int, int, void *, int, char, int);

void f1 (double *, double *, double *, double *,

int, int, int, int, int, int);

#define RESET 0x02

void f1 (double * dPtr1, double *dPtr2, double *dPtr3,

double * dPtr4, int i1, int i2, int i3, int i4,

int i5, int i6)

{

double **ldPtrPtr;

f2(dPtr1, dPtr2, dPtr3, dPtr4, i4, i1, &ldPtrPtr[i4][i1],

RESET, RESET, i6);

}