[clang] [clang][bytecode] Handle corner condition for sign negation (PR #176390)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 16 06:57:27 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;
----------------
tbaederr wrote:

Does `RT::max()` not work?

https://github.com/llvm/llvm-project/pull/176390


More information about the cfe-commits mailing list