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

2025-08-30 Thread Sirui Mu
:52, Jason Merrill wrote: > On 8/28/25 12:33 PM, Sirui Mu wrote: >> Hello, >> >> This is the 2nd version of the patch. Changes made since the initial version: >>    - Implemented Jason's suggestions, move the declaration of first down. >>    - Add signed-off-by to

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

2025-08-28 Thread Sirui Mu
Hello, This is the 2nd version of the patch. Changes made since the initial version: - Implemented Jason's suggestions, move the declaration of first down. - Add signed-off-by to the commit. Tested on x86_64-linux. Signed-off-by: Sirui Mu --- gcc/cp/type

[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