PRB: Typedef Signed Char Treated as Unsigned Char with /J

ID Number: Q31779

5.00 5.10 6.00 6.00a 6.00ax

MS-DOS

buglist5.10 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, when an

item is typedef'ed as signed char, the compiler incorrectly treats

the variable as an unsigned character when compiled with the /J

option. The /J option tells the compiler to interpret all

characters that are not explicitly declared as signed as unsigned

type.

STATUS

Microsoft has confirmed this to be a problem in Microsoft C

versions 5.0, 5.1, 6.0, 6.0a, and 6.0ax. This problem was corrected

in C/C++ version 7.0.

More Information:

The expected output for the following program is:

typedef_signed_char = -1

signed_char = -1

unsigned_char = 255

default_char = 255

However, when compiled with /J, the output is:

typedef_signed_char = 255

signed_char = -1

unsigned_char = 255

default_char = 255

Sample Code

-----------

/* Compile options needed: /J

*/

#include <stdio.h>

typedef signed char SCHAR;

void main(void)

{

SCHAR typedef_signed_char = 255;

signed char signed_char = 255;

unsigned char unsigned_char = 255;

char default_char = 255;

printf( "typedef_signed_char = %ld\n", (long)typedef_signed_char );

printf( " signed_char = %ld\n", (long)signed_char );

printf( " unsigned_char = %ld\n", (long)unsigned_char );

printf( " default_char = %ld\n", (long)default_char );

}

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax