https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98753
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|-Wfree-nonheap-object on |-Wfree-nonheap-object on |Bison generated code |unreachable code with -O0 Known to fail| |11.0 Status|WAITING |NEW Component|c++ |middle-end --- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> --- I can reproduce the warning with no optimization, thanks. At -O0, there are three calls to free in the IL when the warning runs. The second one that triggers it # .MEM_218 = VDEF <.MEM_216> free (yymsg.17_83); is eliminated by copy propagation at -O1. It's not eliminated at -O0 because the optimization isn't done then. So the ultimate root cause of the problem is the same as in pr54202, except at -O0 (the test case there depends on inlining). It would be possible to disable the warning at -O0 to avoid this false positive at the expense of some false negatives. I'm not sure that would be a good solution based on a single report. If more bugs like this are reported we might reconsider. Let me keep this bug open until then.