[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] 0-width named bitfield



On 16/08/11 14:08, Derek M Jones wrote:

perhaps Paulo was alluding to the sentence "If the value is zero,
the declaration shall have no declarator" in 6.7.2.1 paragraph 3 of C99.

There was/is existing practice of using zero width bit-fields
to tell the compiler to stop assigning bit-fields into the
current storage unit and move onto the next one.


But the bitfields need to be _unnamed_.

Bad (generated by csmith):
$ cat bitfield.c
struct bf {
  int x : 5;
  int y : 4;
  int u : 0;
  int z : 10;
};
$ gcc -Wall -std=c99 -c bitfield.c
bitfield.c:4:3: error: zero width for bit-field ‘u’


Good:
$ cat bitfield.c
struct bf {
  int x : 5;
  int y : 4;
  int : 0;
  int z : 10;
};
$ gcc -Wall -std=c99 -c bitfield.c
$

--
PMatos


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog