![]() |
![]() |
0457 | ![]() |
||||
![]() | |||||||
| Constraint violations | REFERENCE - ISO:C90-6.3.3.2 Address and Indirection Operators - Constraints | ||||||
This is a constraint error It might be possible to take the address of the struct/union which contains the bit-field, but it is never possible to take the address of a bit-field itself. A bit-field, by definition, can occupy part or all of a byte or word. The
& (address of) operator returns the addressable location of an object in terms of bytes and so cannot specify exactly the bit-field location within a byte or word.
For example:
/*PRQA S 2211,3198,3199,3203,3621 ++*/
struct flags {
unsigned int hi:1;
unsigned int lo:1;
unsigned int ins:1;
unsigned int ovr:1;
};
int main(void)
{
struct flags f;
int *ip;
unsigned int i;
f.hi = 0;
f.lo = 0;
f.ins = 0;
f.ovr = 0;
ip = &(f.hi); /* Message 0457 */
ip = &f.lo; /* Message 0457 */
i = f.ins;
return 0;
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |