ID Number: Q79847
6.00 6.00a 6.00ax
MS-DOS
buglist6.00 buglist6.00a buglist6.00ax fixlist7.00
Summary:
PROBLEM ID: C9201001
SYMPTOMS
In Microsoft C versions 6.0, 6.0a, and 6.0ax, the initialization of
a tentative definition may not work properly if the tentative
definition of a structure and the initialization of the structure
are separated by any code. The variable will be initialized to 0
(zero) instead of the value specified.
A tentative definition is a declaration of an identifier with file
scope, no initializer, and either no storage class specifier or a
static storage class specifier. A declaration with an initializer
can be given for a tentative definition in the same file. This
should have the effect of initializing the variable specified by
the identifier. The sample code below demonstrates this problem.
RESOLUTION
The following are valid workarounds:
1. Compile with the /qc (quick compile) option.
-or-
2. Place the tentative definition and the initialization so that
there is no intervening code.
STATUS
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:
Sample Code
-----------
/* Compile options needed: none
*/
#include <stdio.h>
struct sint
{
int val;
};
static struct sint var;
void main ()
{
printf ("%d\n", var.val);
}
static struct sint var= {1};