[gnu.gcc.bug] Bitfield messes up sizeof

@read.columbia.edum) (f) (10/22/89)

Using gcc 1.35 on a sun4:

Apparently, including bitfields in a structure definition messes up
the compiler's computation of the correct size of the structure. 
gcc reports sizeof(ResultStruct) is 6, while sizeof(ResultStruct2) is 8.
The correct answer is 8, because of alignment issues on the sun4.

typedef struct NSR {
  poslongnumber thestate : 24;  /* if thestate&(1<<23), actual state is
                                -(thestate&((1<<23)-1)) in the call chain */
  poslongnumber inp : 1;      /* was there input in producing this state? */
  poslongnumber outp : 1;      /* was there output from this state? */
  poslongnumber bits : 4;      /* the bits for this state */
  poslongnumber last : 1;      /* TRUE iff I am last in sequence.  */
  poslongnumber misc : 1;      /* pad to 32 bits */
} NSR, * NSRP;

/* all uninitialized NSRs look like NONSR, which is guaranteed not to match
   anything real NSR. */
extern NSR NONSR;
/* the NSR0 has everything set to 0 */
extern NSR NSR0;


/* a structure that remembers the state and the char */
typedef struct ResultStruct {
NSR thensr;
posnumber inchar;  /* input char after translation */
} ResultStruct, * ResultStructP;

typedef struct ResultStruct2 {
longnumber foo;
posnumber inchar;
} ResultStruct2, * ResultStruct2P;


-steve