FinalCheck causes bitfields to not work correctly.

0 Likes

Problem:

The following is a minimal program that demonstrates a problem using Bounds Checker's compile-time instrumentation with code that uses bit-fields.

I worked around this by temporarily replacing the 1-bit bit-fields in the structure in our product that caused the problem with integers, but would like to know whether a fix to Bounds Checker is available, since other parts of our software might be similarly affected.

/* bitfield.c - BC 5.02 bitfield bug demonstration program.

/*  "cl bitfield.c" - executable works*/

/*  "nmcl bitfield.c" - executable gives access violation when run

/*  The original structure had 11 1-bit bitfields followed by lots

/*  of other members, but this is all that is needed.

typedef struct

{

  int reading:1;

}

MyStruct;

/*  The same problem arises wherever the structure is located.

/*  It can be on the stack or dynamically allocated

static MyStruct m = { -1 };

int main(void)

{

  int reading;

  /*  The direct printf() of the bit field works, but the assingment

  /*  to an int variable fails with an access violation

  printf("m.reading %d

", m.reading);

  reading = m.reading;

  printf("reading %d

", reading);

  return (0);

}

Resolution:

We're aware of this problem.  At this point the only work around is to use the /NMIgnore to exclude either the modules or functions that use instrumentation from being finalchecked.

Old KB# 12187
Comment List
Anonymous
Related Discussions
Recommended