Serosh 7c64723f34
[clang][bytecode] Fix stack corruption in pointer arithmetic discard (#176555)
The bytecode compiler was ignoring the DiscardResult flag in 
VisitPointerArithBinOp
, causing pointer addition and subtraction results to persist on the
stack when they should have been popped (e.g., in comma expressions).
This led to stack corruption and assertion failures in subsequent
operations that encountered an unexpected pointer on the stack.

This patch refactors the unified addition/subtraction logic to ensure
the result is properly popped when DiscardResult is true.

Fixes #176549
2026-02-04 20:18:55 -08:00

8 lines
223 B
C++

// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
const char a[4] = "abc";
void foo() {
int i = 0;
i = 1 > (a + 1, sizeof(a)); // expected-warning {{left operand of comma operator has no effect}}
}