[clang] [clang][bytecode] Handle corner condition for sign negation (PR #176390)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 16 07:22:12 PST 2026
================
@@ -2888,7 +2888,9 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS,
S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS.toAPSInt();
if (!S.noteUndefinedBehavior())
return false;
- RHS = -RHS;
+
+ RHS = RHS.isMin() ? RT(APSInt::getMaxValue(RHS.bitWidth(), false)) : -RHS;
----------------
hax0kartik wrote:
Nope, because [IntegralAp](https://github.com/llvm/llvm-project/blob/a0e0775d91859d6ca32efc5fb8644b6281e98593/clang/lib/AST/ByteCode/IntegralAP.h) class does not define a max method.
https://github.com/llvm/llvm-project/pull/176390
More information about the cfe-commits
mailing list