MS C 5.1 bug: global variable definition

Christopher D. Brown cb at sequoia.UUCP
Thu Jun 29 00:36:14 AEST 1989


Use the Microsoft C 5.1 command line
   CL /AL /Gt0 /Fa /c
to generate assembly and object code for both BUG.C and NOBUG.C.
Note that only NOBUG produces the public symbol _a_var.

Source file BUG.C is as follows:
   int near a_var;
Generated file BUG.ASM includes the following code:
   _BSS   SEGMENT
   COMM NEAR _a_var: BYTE: 2
   _BSS   ENDS

Source file NOBUG.C is as follows:
   int near a_var = 0;
Generated file NOBUG.ASM includes the following (correct) code:
   PUBLIC _a_var
   _DATA  SEGMENT
   _a_var DW      00H
   _DATA  ENDS

Christopher D. Brown



More information about the Comp.lang.c mailing list