Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Casting pointers or references to incomplete classes can result in bad addresses. Deleting a pointer to an incomplete class results in undefined behavior if the class has a nontrivial destructor. Doing so can cause program termination, a runtime signal, or resource leaks.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

EXP57-CPP

Medium

Unlikely

Medium

P4

L3

Automated Detection

Tool

Version

Checker

Description

Astrée

Include Page
Astrée_V
Astrée_V

delete-with-incomplete-type

Coverity6.5DELETE_VOIDFully implemented
Clang
Include Page
Clang_V
Clang_V
-Wdelete-incomplete
 

CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.CAST.PC.INC

Conversion: pointer to incomplete
Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C++3112
Klocwork
Include Page
Klocwork_V
Klocwork_V
CERT.EXPR.DELETE_PTR.INCOMPLETE_TYPE
LDRA tool suite
Include Page
LDRA_V
LDRA_V

169 S, 554 S

Enhanced Enforcement

Parasoft C/C++test
9.5PB-54, PB-55 Parasoft Insure++  Runtime detection
Include Page
Parasoft_V
Parasoft_V

CERT_CPP-EXP57-a
CERT_CPP-EXP57-b

Do not delete objects with incomplete class at the point of deletion
Conversions shall not be performed between a pointer to an incomplete type and any other type

Parasoft Insure++

Runtime detection
Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C++: EXP57-CPPChecks for conversion or deletion of incomplete class pointer
RuleChecker
Include Page
RuleChecker_V
RuleChecker_V
delete-with-incomplete-type


Related Vulnerabilities

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

Bibliography

[Dewhurst 2002]Gotcha #39, "Casting Incomplete Types"
[ISO/IEC 14882-2014]

Subclause 4.10, "Pointer Conversions"
Subclause 5.2.9, "Static Cast"
Subclause 5.2.10, "Reinterpret Cast"
Subclause 5.3.5, "Delete"
Subclause 5.4, "Explicit Type Conversion (Cast Notation)"

[Sutter 2000]"Compiler Firewalls and the Pimpl Idiom"

...


...