Re: [PATCH] c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]

2025-06-29 Thread Jason Merrill
On 6/28/25 3:08 AM, Jakub Jelinek wrote: On Fri, Jun 27, 2025 at 06:49:12PM -0400, Jason Merrill wrote: On 6/27/25 5:58 PM, Jakub Jelinek wrote: The following testcase is miscompiled since the introduction of UBSan, cp_build_array_ref COND_EXPR handling replaces (cond ? a : b)[idx] with cond ?

Re: [PATCH] c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]

2025-06-28 Thread Jakub Jelinek
On Fri, Jun 27, 2025 at 06:49:12PM -0400, Jason Merrill wrote: > On 6/27/25 5:58 PM, Jakub Jelinek wrote: > > The following testcase is miscompiled since the introduction of UBSan, > > cp_build_array_ref COND_EXPR handling replaces > > (cond ? a : b)[idx] with cond ? a[idx] : b[idx], but if there a

Re: [PATCH] c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]

2025-06-27 Thread Jason Merrill
On 6/27/25 5:58 PM, Jakub Jelinek wrote: Hi! The following testcase is miscompiled since the introduction of UBSan, cp_build_array_ref COND_EXPR handling replaces (cond ? a : b)[idx] with cond ? a[idx] : b[idx], but if there are SAVE_EXPRs inside of idx, they will be evaluated just in one of the

[PATCH] c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]

2025-06-27 Thread Jakub Jelinek
Hi! The following testcase is miscompiled since the introduction of UBSan, cp_build_array_ref COND_EXPR handling replaces (cond ? a : b)[idx] with cond ? a[idx] : b[idx], but if there are SAVE_EXPRs inside of idx, they will be evaluated just in one of the branches and the other uses uninitialized