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
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Geoffrey Aldrich shared this idea  ·   ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Geoffrey Aldrich commented  · 

        Yes, that's just a typo in my example here. It doesn't reflect the actual code.

      • Anonymous commented  · 

        The data type has been wrongly typed. The data type should be "unsigned" instead of "unisgned" as mentioned in code.

      Feedback and Knowledge Base