Versions Compared

Key

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

...

If expressions that appear to produce side effects are an unevaluated operand, the results may be different than expected. Depending on how this result is used, it can lead to unintended program behavior.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

EXP52-CPP

Low

Unlikely

Low

P3

L3

Automated Detection

Tool

Version

Checker

Description

Astrée

Include Page
Astrée_V
Astrée_V

sizeof
Partially checked
Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC++-EXP52
Clang
Include Page
Clang_V
Clang_V
-Wunevaluated-expression
 

CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.STRUCT.SE.SIZEOF

Side Effects in sizeof

Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C++3240, C++3241
Klocwork
Include Page
Klocwork_V
Klocwork_V

MISRA.SIZEOF.SIDE_EFFECT

 

LDRA tool suite
Include Page
LDRA_V
LDRA_V

54 S, 133 S

Partially implemented

Parasoft C/C++test
9.5JSF-166, JSF-166_{b,c} PRQA QA-C++ Include PagePRQA QA-C++_VPRQA QA-C++_V

3240, 3241

  PRQA QA-C 9.1 3240, 3241
Include Page
Parasoft_V
Parasoft_V

CERT_CPP-EXP52-a
CERT_CPP-EXP52-b
CERT_CPP-EXP52-c
CERT_CPP-EXP52-d
CERT_CPP-EXP52-e

The operand of the sizeof operator shall not contain any expression which has side effects
Object designated by a volatile lvalue should not be accessed in the operand of the sizeof operator
The function call that causes the side effect shall not be the operand of the sizeof operator
The operand of the 'typeid' operator shall not contain any expression that has side effects
The operand of the 'typeid' operator shall not contain a function call that causes side effects

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C++: EXP52-CPPChecks for logical operator operand with side effects
RuleChecker
Include Page
RuleChecker_V
RuleChecker_V
sizeof
Partially checked
 

Related Vulnerabilities

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

Related Guidelines

Bibliography

[ISO/IEC 14882-2014]Clause 5, "Expressions"
Subclause 20.2.5, "Function Template declval"
 
 


...