ID Number: Q77130
6.00 6.00a 6.00ax | 6.00 6.00a
MS-DOS | OS/2
buglist6.00 buglist6.00a buglist6.00ax fixlist7.00
Summary:
PROBLEM ID: C9109004
SYMPTOMS
Microsoft C versions 6.0, 6.0a, and 6.0ax may generate the warning
C4058 on lines where no errors exist. This error should only be
generated in memory models that use near pointers and where DS !=
SS and DS is not loaded upon function entry (/Aw). Microsoft C
erroneously generates this error in large, compact, and huge
models. This problem does not occur when using the quick compile
option (/qc). In all cases to date, correct code has been generated.
RESOLUTION/STATUS
After checking to see if the code generated is correct and the
error is invalid, the warning can be ignored.
Microsoft has confirmed this to be a problem in Microsoft C
versions 6.0, 6.0a, and 6.0ax. This problem was corrected in C
version 7.0.
More Information:
In memory models that use near pointers, the error message should be
generated because the address returned may or may not be invalid,
depending on what segment is set in the DS register. Under memory
models that use far pointers, the error message should not be
generated because the correct address can always be calculated through
SS.
The following errors are generated when the sample code below is
compiled with /ALw:
Sample.c(8) : warning C4058:
address of automatic (local) variable taken, DS != SS
Sample.c(12) : warning C4058:
address of automatic (local) variable taken, DS != SS
Sample Code
-----------
/* Compile options needed: /ALw /c
*/
int *function(int number, int *pointer){
pointer = &number;
if (&number); /* C4058 is generated here */
if (pointer);
return &number; /* C4058 is generated here */
}
Additional reference words: 6.00 6.00a 6.00ax