EGCS 2.91.66 Bug: sizeof() + struct problem (char == and != int)

Tobias Burnus
Fri Sep 17 17:43:00 GMT 1999


Using this very short programm:
#include <stdio.h>

struct BeginPage{
  short PageNumber;
  int Flags;
  int BB_x;

struct BeginPage2{
  short PageNumber;
  int Flags;
  char BB_x;

void main(int argc, char *argv[])
  printf("%d -- %d -- %d\n",sizeof(char),sizeof(short),sizeof(int));

I get this output:
1 -- 2 -- 4
whereas I had expected it to be 10 and 7 !!

This is with egcs 2.91.66, which comes with SuSE Linux 6.2
(Installed gcc- without the binaries, called gccfont.rpm,
since I use egcs-990708-3.rpm)

The System is glibc 2.1 based and runing on a Pentium II.

The commandline was (besides g++
gcc -v --save-temps
Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
 /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/cpp -lang-c++ -v -undef -D__GNUC__=2
-D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Di386
-D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__ -D__linux__
-D__unix -D__i386 -D__linux -Asystem(posix) -D__EXCEPTIONS -Asystem(unix)
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_i486__
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/cc1plus test2.ii -quiet -dumpbase -version -o test2.s
GNU C++ version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i486-linux)
compiled by GNU C version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release).
 /usr/i486-linux/bin/as -V -Qy -o test2.o test2.s
GNU assembler version 2.9.1 (i486-linux), using BFD version
 /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/collect2 -m elf_i386 -dynamic-linker
/lib/ /usr/lib/crt1.o /usr/lib/crti.o
-L/usr/lib/gcc-lib/i486-linux/egcs-2.91.66 -L/usr/i486-linux/lib test2.o -lgcc
-warn-common -lc -lgcc /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/crtend.o


More information about the Gcc-bugs mailing list