Bitfield size isn't error checked by Lint
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,
So, basically, I was trying to fit 14 bits into an 8-bit wide variable.
Could you please clarify the specific circumstance you would like diagnosed by PC-lint Plus here? It is not clear what the underlying bug you encountered was from the example you provided.
Geoffrey Aldrich commented
Yes, that's just a typo in my example here. It doesn't reflect the actual code.
The data type has been wrongly typed. The data type should be "unsigned" instead of "unisgned" as mentioned in code.