-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathDependenceOnOrderOfScalarEvaluationForSideEffects.ql
More file actions
34 lines (32 loc) · 1.46 KB
/
DependenceOnOrderOfScalarEvaluationForSideEffects.ql
File metadata and controls
34 lines (32 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @id c/cert/dependence-on-order-of-scalar-evaluation-for-side-effects
* @name EXP30-C: Do not depend on the order of scalar object evaluation for side effects
* @description Depending on the order of evaluation for side effects for evaluation of scalar
* objects that are unsequenced results in undefined behavior.
* @kind problem
* @precision high
* @problem.severity warning
* @tags external/cert/id/exp30-c
* correctness
* external/cert/severity/medium
* external/cert/likelihood/probable
* external/cert/remediation-cost/medium
* external/cert/priority/p8
* external/cert/level/l2
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
import codingstandards.cpp.SideEffect
import codingstandards.c.Ordering
import codingstandards.c.orderofevaluation.VariableAccessOrdering
import Ordering::Make<VariableAccessInFullExpressionOrdering> as FullExpressionOrdering
from FullExpr e, ScalarVariable v, VariableEffect ve, VariableAccess va1, VariableAccess va2
where
not isExcluded(e, SideEffects1Package::dependenceOnOrderOfScalarEvaluationForSideEffectsQuery()) and
e = va1.(ConstituentExpr).getFullExpr() and
va1 = ve.getAnAccess() and
FullExpressionOrdering::isUnsequenced(va1, va2) and
v = va1.getTarget()
select e, "Scalar object referenced by $@ has a $@ that is unsequenced in relative to another $@.",
v, v.getName(), ve, "side-effect", va2, "side-effect or value computation"