https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111904
Alexandre Oliva <aoliva at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Alexandre Oliva <aoliva at gcc dot gnu.org> --- AFAICT the test expects stackbuf to remain unchanged across do_secret_stuff calls, even though it's free stack space, but calling the hardcfr checker may scribble over it. But the real kicker is that, at -O3, do_secret_stuff gets two different versions for each of the pass numbers, and in the specialization for odd passes the stackbuf is optimized away entirely, and the visited bitmap ends up assigned at stack space that overlaps with the stackbuf allocated during the previous even pass, and that's what gets memcmp to fail at every execution. Adding attributes noclone and noipa to do_secret_stuff avoids the specializations, and then the test passes even at -O3.