PRB: DS Used Instead of Base Segment for Based Ptr Dereference

ID Number: Q67035

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

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

Summary:

SYMPTOMS

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, and 6.0ax, there are

some situations where a based pointer will be incorrectly

dereferenced in relation to the default data segment, rather than

to the segment on which the pointer is based. This problem occurs

only with the QuickC Compiler or when the /qc (quick compile)

option is used with the C Optimizing Compiler.

STATUS

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

6.0a, and 6.0ax and QuickC versions 2.5 and 2.51 (buglist2.50 and

buglist2.51). This problem was corrected in C/C++ version 7.0.

More Information:

The sample program below demonstrates this problem. When the code is

compiled with C versions 6.0, 6.0a, or 6.0ax and the /qc option is

specified, the value returned from the function is DS:0, instead of

0:0. By eliminating the /qc option, the expected value is returned.

Sample Code

-----------

/* Compile options needed: /qc

*/

#include <stdio.h>

#include <stdlib.h>

char far *get_address(void);

void main(void)

{

char far *addr;

addr = get_address();

printf("Address = %Fp -- Address expected = 0000:0000\n", addr);

}

char far *get_address(void)

{

_segment base = 0;

return ( (char far *)(base:>NULL) );

}

Additional reference words: 6.00 6.00a 6.00ax