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

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



Paulo,

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_.

I agree.
I was not disagreeing with Pascal.


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
$


--
Derek M. Jones                         tel: +44 (0) 1252 520 667
Knowledge Software Ltd                 mailto:derek@knosof.co.uk
Source code analysis                   http://www.knosof.co.uk