Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

...

Noncompliant Code Example (Bit-Field Overlap)

In the following this noncompliant code example, assuming 8 bits to a byte, if bit-fields of 6 and 4 bits are declared, is each bit-field contained within a byte, or are the bit-fields split across multiple bytes?

...

Making invalid assumptions about the type of type-cast data, especially bit-fields, can result in unexpected data values.

Recommendation

Severity

Likelihood

Remediation Cost

Detectable

Repairable

Priority

Level

EXP11-C

Medium

Probable

No

Medium

No

P8

P4

L2

L3

Automated Detection

Tool

Version

Checker

Description

Astrée
Include Page
Astrée_V
Astrée_V

Supported: Astrée reports runtime errors resulting from invalid assumptions.
Compass/ROSE

 

 



Can detect violations of this recommendation. Specifically, it reports violations if

    • A pointer to one object is type cast to the pointer of a different object
    • The pointed-to object of the (type cast) pointer is then modified arithmetically
Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C0310, C0751
LDRA tool suite
Include Page
LDRA_V
LDRA_V
94

554 S

95 S

Fully implemented

PRQA QA-C
Polyspace Bug Finder

Include Page

PRQA

Polyspace Bug Finder_V

PRQA

Polyspace Bug Finder_V

0310Partially implemented
CERT C: Rec. EXP11-C

Checks for bit fields accessed using pointer.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this recommendation on the CERT website.

Related Guidelines

Bibliography

[Plum 1985]Rule 6-5: In portable code, do not depend upon the allocation order of bit-fields within a word

...


...

Image Modified Image Modified Image Modified