Skip to content

Commit 2908570

Browse files
committed
C++: Do not consider expression results discardable when there is a conversion
1 parent b185cc8 commit 2908570

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4146,7 +4146,8 @@ predicate exprNeedsCopyIfNotLoaded(Expr expr) {
41464146
private predicate exprImmediatelyDiscarded(Expr expr) {
41474147
exists(ExprStmt s |
41484148
s = expr.getParent() and
4149-
not exists(StmtExpr se | s = se.getStmt().(BlockStmt).getLastStmt())
4149+
not exists(StmtExpr se | s = se.getStmt().(BlockStmt).getLastStmt()) and
4150+
not exists(Conversion c | c = expr.getConversion*() and not isTransparentConversion(c))
41504151
)
41514152
or
41524153
exists(CommaExpr c | c.getLeftOperand() = expr)

0 commit comments

Comments
 (0)