https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113551
--- Comment #19 from rguenther at suse dot de <rguenther at suse dot de> --- On Tue, 23 Jan 2024, pinskia at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113551 > > --- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> --- > (In reply to Yuxuan Shui from comment #12) > > I think this is the MRE: > > > > > > void bug(struct obj *dso) { > > if (&dso->i) { > > if (dso == (void *)0) > > return; > > > > assert_not_null(dso); > > } > > } > > Except that is undefined ... > Manually unswitching introduces the undefined behavior in the code. > So even though the code was unswitched before GCC 13 incorrectly, GCC didn't > take into that account before hand. > > I am 99% sure what is happening is GCC is see `if (a+1)` and then assuming a > can't be a nullptr. Which is due to undefinedness there of adding 1 to an null > ptr ... (for C that is). > > Basically the unswitch is the issue ... Or we maybe we should turn `if (a+1)` > into just `if (a)` ... Likewise for `if (&a->i)` into `if (a)` It's not undefined on GIMPLE. As said I believe this was fixed for GCC 14 but appearantly not backported. bisection should tell