Bug 000189

When Created: 11/21/1997 07:47:35
Against DJGPP version: 2.01
By whom:
Abstract: sizeof(unsigned) returns 4, not 2
The sizeof operator returns 4, for an unsigned.

#include <stdio.h>
main() {
printf( "sizeof(unsigned) = %u\n", sizeof(unsigned) );


sizeof(unsigned) = 4

Solution added: 11/21/1997 18:40:27
By whom:
it isn't a bug

in p-mode the defualt integer size is long (4 bytes) instead of 
real modes default short (2) bytes.

sizeof(unsigned short) = 2
sizeof(unsigned long) = 4

//default varible is 4 bytes 
sizeof(unsigned) = sizeof(unsigned long)

Note added: 12/16/1997 07:22:25
By whom:
It's not protected-mode which does that!  DJGPP makes 32-bit programs.
Therefore, integers are four bytes long.  (Protected-mode on the 286
micro-processor is 16 bits.  So, "int"s are the same as "short int"s, there.)

Closed on 04/12/1999 10:00:03: This is not a bug, but an expected behavior of GCC.
By whom:

  webmaster     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010