https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118763
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Summary|[12/13/14/15 regression] |[12/13/14/15 regression] |memory leak involving early |memory leak involving early |return from statement |return from statement |expressions |expressions since r12-6325 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Started with r12-6325-gad64a821970ef5547d77ece22d302b0e599ae0d2 D.2863 = operator new (4); D.2864 = 1; try { if (x != 0) goto <D.2873>; else goto <D.2874>; <D.2873>: D.2869 = 0B; // predicted unlikely by early return (on trees) predictor. return D.2869; <D.2874>: MEM[(int *)D.2863] = 1; D.2864 = 0; D.2869 = D.2863; return D.2869; } catch { if (D.2864 != 0) goto <D.2870>; else goto <D.2871>; <D.2870>: operator delete (D.2863, 4); goto <D.2872>; <D.2871>: <D.2872>: } I think the problem is in using CLEANUP_EH_ONLY cleanup here which is turned into try/catch, rather than one that is turned into try/finally. Because that one would DTRT here already, the D.2864 guard variable is already cleared if new int succeeded.