[clang] fix(95366): enhance cast operation safety with LValue validation (PR #95479)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 06:30:05 PDT 2024
================
@@ -9325,6 +9325,9 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
Result.IsNullPtr = false;
return true;
} else {
+ if (!Value.isLValue())
----------------
AaronBallman wrote:
I think it's worth adding a comment here explaining under what circumstances this wouldn't be an lvalue. Something along the lines of "In rare instances, the value isn't an lvalue. For example, when the value is the difference between the address of two labels. We reject that as a constant expression because we can't compute a valid offset to convert into a pointer."
https://github.com/llvm/llvm-project/pull/95479
More information about the cfe-commits
mailing list