C4058 Error May Be Incorrect with /qc and /MT options

ID Number: Q62182

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax

Summary:

The C4058 warning message may be generated in error if the /qc switch

(quick compile) is used in conjunction with the /MT switch in

Microsoft C versions 6.0, 6.0a, or 6.0ax. If the warning disappears

when the /qc switch is removed, the warning may be ignored.

More Information:

The sample code below may be used to illustrate this problem. The

following warning is given on the three assignment statements that

make assignments the variable "a":

Warning C4058: address of automatic (local) variable taken, DS != SS

The /MT switch (used for multithread programs) implies /ALw, which

instructs the compiler to assume DS != SS with DS fixed. Typically,

this warning will come about when a program de-references a near

pointer that is automatic (local). In this case, the warning is

invalid.

The following are two different ways of working around the problem:

1. Compile with /ALu. This assumes that DS != SS, and causes DS to be

reloaded upon function entry.

2. Turn off the /qc compile option.

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

and 6.0ax. We are researching this problem and will post new

information here as it becomes available.

Sample Code

-----------

/* Compile options needed: /c /qc /MT /W4

*/

#include <math.h>

void main (void) ;

void main (void)

{

double a ;

a = cos (3.2) ;

a = sin (2.2) ;

a = atan (5.0) ;

}

Additional reference words: 6.00 6.00a 6.00ax