open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
989 stars 162 forks source link

Error when initializing multiple bit fields #1283

Open fafner2000 opened 6 months ago

fafner2000 commented 6 months ago

Hello,

I found an issue when initializing multiple bit fields:

typedef struct
  {
  int field1,field2;
  unsigned int bit1:1,bit2:1;
  } some_struct;

static const some_struct S=
  {
  .field1=1,
  .field2=2,
  .bit1  =0,
  .bit2  =1,  // <- E1063: Missing operand
  };

It gives this error: test.c(27): Error! E1063: Missing operand

This error doesn't depend on the presence of the trailing comma. Using -za99 doesn't change anything either. However, the error goes away when removing one of the bit field initializers (either bit1 or bit2). The error also goes away when using array-style initialization:

static const some_struct S={1,2,0,1};

I had a watch in the ISO/IEC 9899:1999 reference, section 6.7.8 , to make sure there wasn't some restriction on bit fields initialization, but didn't see anything special about them. Moreover, everything compiles fine with gcc.

jmalak commented 6 months ago

1262 #1274

jmalak commented 5 months ago

This case is now fixed.

fafner2000 commented 5 months ago

I downloaded the release and replaced my current version: it fixes my test program.