I suggest you ...

Bitfield size isn't error checked by Lint

Greetings,
I've been using Lint for the past 5 years and it's been a very useful tool for me. However, today I discovered an error in my C code that wasn't caught by Lint, and it may be useful if it could be flagged. The error is trying to divide a variable in a structure definition into bitfields where the combined size of the bitfields exceeds the size of the underlying variable.

For example, my bad code was like this:

typedef struct dummy_struct
{
unisgned char field1: 6,
field2: 6,
field3: 1,
field4: 1;
} DUMMY;

So, basically, I was trying to fit 14 bits into an 8-bit wide variable.

Regards,
Geoffrey

3 votes
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
Geoffrey Aldrich shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base