Microsoft KB Archive/69221

PRB: Incorrect Code Generated for Returning a Far Pointer PSS ID Number: Q69221 Article last modified on 12-09-1992 PSS database name: S_QuickC

2.50 2.51

MS-DOS

Summary:

SYMPTOMS The Microsoft QuickC Compiler versions 2.5 and 2.51 and the quick compile options (/qc) of the Microsoft C Compiler versions 6.0 and 6.0a may generate incorrect code for returning a far pointer. The far pointer returned does not have a valid segment value.

RESOLUTION Assign a temporary variable to the desired pointer value and return the temporary pointer. Under C 6.0 and 6.0a, compiling without /qc will also work.

STATUS Microsoft has confirmed this to be a problem in QuickC versions 2.5 and 2.51 and in C versions 6.0 and 6.0a (buglist6.00 buglist6.00a). We are researching this problem and will post new information here as it becomes available.

More Information:

Compiling the following program with any optimizations under QuickC, or with the /qc option and any optimizations under C 6.0, will demonstrate the problem. The following sample code demonstrates the problem.

Sample Code

 * 1) include  #include  char far *myfunc(int);

struct REC { char rec[8]; } far *anchor;

void main(void) { char far *slot; slot= myfunc(0); printf (“anchor = %08lx”,anchor); printf (“slot = %08lx”,slot); }

char far myfunc(int recno) { anchor= (struct REC far ) _fmalloc(sizeof(struct REC)); return(&anchor->rec[recno%8]); }

Copyright Microsoft Corporation 1992.