Code deactivated by constant false condition
(DEACTIVATED_CODE)
R2026bCode segment deactivated by #if 0 preprocessor
directive
Description
This defect occurs when a preprocessor conditional (#if or
#elif) uses a compile-time constant expression that always evaluates to
zero. The code within the disabled block is never compiled.
Risk
Code deactivated by #if 0 is never compiled. Risks include:
The compiler cannot test or verify the disabled code.
The disabled code may silently become stale as surrounding code evolves.
Maintenance confusion arises about whether the code is intentionally disabled or forgotten.
Latent defects may surface if the directive is later changed.
Fix
To fix this defect:
Remove the
#if 0block entirely if the code is no longer needed.Replace
#if 0with a named macro (for example,#if FEATURE_ENABLED) so the intent is explicit and the deactivation is conditional rather than absolute.If the code serves as a reference or placeholder, move it to a comment or version control history.
If you do not want to fix the issue, add comments to your result or code to avoid another review.
Examples
Result Information
| Group: Data flow |
| Language: C | C++ |
| Default: off |
Command-Line Syntax:
DEACTIVATED_CODE
|
| Impact: Low |
PQL Name:
std.defects.DEACTIVATED_CODE
|
Version History
Introduced in R2013bSee Also
Find defects
(-checkers) | Unreachable
code | Useless
if | Dead
code
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)