https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89009
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> --- > Richi do you have any idea what? So it's caused by fact that IPA pure-const promotes S3::bar to be const: Visiting static void S3::bar()/1 state:const looping 0 Call to static void S2::_ZN2S23barEv.localalias()/5 state:const looping:0 Result const looping 0 Function found not to call free: static void S3::bar() Function found to be const: static void S3::bar() Declaration updated to be const: static void S3::bar() Then DCE is happy to remote the function as it's supposed to not have a side effect.