diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index a95353fd2943c..705ab1ec8e8ab 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -1000,7 +1000,10 @@ bool Compiler::VisitPointerArithBinOp(const BinaryOperator *E) { if (!visitAsPointer(RHS, *RT) || !visitAsPointer(LHS, *LT)) return false; - return this->emitSubPtr(classifyPrim(E->getType()), E); + PrimType IntT = classifyPrim(E->getType()); + if (!this->emitSubPtr(IntT, E)) + return false; + return DiscardResult ? this->emitPop(IntT, E) : true; } PrimType OffsetType; diff --git a/clang/test/AST/ByteCode/literals.cpp b/clang/test/AST/ByteCode/literals.cpp index 13d6c4feb3500..662823c49cd4a 100644 --- a/clang/test/AST/ByteCode/literals.cpp +++ b/clang/test/AST/ByteCode/literals.cpp @@ -980,6 +980,8 @@ namespace DiscardExprs { __uuidof(number); // both-error {{cannot call operator __uuidof on a type with no GUID}} requires{false;}; + constexpr int *p = nullptr; + p - p; return 0; }