Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1518,6 +1518,13 @@ // The Inv doesn't change anything, so skip it if we don't need the result. return DiscardResult ? this->emitPop(*T, E) : this->emitInvBool(E); case UO_Minus: // -x + // Emit negated integers directly. + if (const auto *IL = dyn_cast(SubExpr)) { + if (DiscardResult) + return true; + APSInt V = APSInt(IL->getValue(), /*IsUnsigned=*/false); + return this->emitConst(-V, E); + } if (!this->visit(SubExpr)) return false; return DiscardResult ? this->emitPop(*T, E) : this->emitNeg(*T, E);