Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

An object has a storage duration that determines its lifetime. There are three storage durations: static, automatic, and allocated.

Wiki MarkupAccording to C99 \[ [ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\]

The lifetime of an object is the portion of program execution during which storage is guaranteed to be reserved for it. An object exists, has a constant address, and retains its last-stored value throughout its lifetime. If an object is referred to outside of its lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when the object it points to reaches the end of its lifetime.

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

DCL30-C

high

probable

high

P6

L2

Automated Detection

Tool

Version

Checker

Description

Section

LDRA tool suite

Include Page
c:LDRA_Vc:
LDRA_V
Section

42 D
71 S

Section

Fully Implemented

Section

Fortify SCA

Section

V. 7.6.0

 

Section

can detect violations when an array is declared in a function and then a pointer to that array is returned

Section

Splint

Include Page
c:Splint_Vc:
Splint_V

 

 

Section

Compass/ROSE

 

 

Section

can detect violations of this rule. It automatically detects returning pointers to local variables. Detecting more general cases, such as examples where static pointers are set to local variables which then go out of scope would be difficult.

Section

Coverity Prevent

Include Page
c:Coverity_Vc:
Coverity_V
Section

RETURN_LOCAL

Section

finds many instances where a function will return a pointer to a local stack variable. Coverity Prevent cannot discover all violations of this rule, so further verification is necessary.

Section

Klocwork

Include Page
c:Klocwork_Vc:
Klocwork_V
Section

LOCRET.*

 

...

MISRA Rule 8.6

Bibliography

Wiki Markup\[[Coverity 2007|AA. Bibliography#Coverity 07]\]

...

      02. Declarations and Initialization (DCL)