[llvm] Avoid undefined behavior in shift operators during constant folding of DIExpressions. (PR #116466)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 16 01:02:29 PST 2024
================
@@ -59,12 +59,14 @@ foldOperationIfPossible(uint64_t Const1, uint64_t Const2,
return Const1 - Const2;
}
case dwarf::DW_OP_shl: {
- if ((uint64_t)countl_zero(Const1) < Const2)
+ if (Const2 >= std::numeric_limits<uint64_t>::digits ||
+ (uint64_t)countl_zero(Const1) < Const2)
----------------
tschuett wrote:
Drive-by nit: named casts are preferred, i.e., static_cast.
https://github.com/llvm/llvm-project/pull/116466
More information about the llvm-commits
mailing list