Re: [PATCH] c++: Fix miscompilation on array subscription with COND_EXPR as the array

2025-08-28 Thread Jason Merrill
On 8/28/25 9:48 AM, Sirui Mu wrote: Hello, The following minimum reproducer would miscompile with vanilla gcc: extern int x[10], y[10]; bool g(); void f() { 0[g() ? x : y] = 1; } gcc would mistakenly treat the subexpression (g() ? x : y) as a prvalue and move that array to stack. The

[PATCH] c++: Fix miscompilation on array subscription with COND_EXPR as the array

2025-08-28 Thread Sirui Mu
Hello, The following minimum reproducer would miscompile with vanilla gcc: extern int x[10], y[10]; bool g(); void f() { 0[g() ? x : y] = 1; } gcc would mistakenly treat the subexpression (g() ? x : y) as a prvalue and move that array to stack. The following assignment would then write to