https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78832
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 40351 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40351&action=edit gcc7-pr78832.patch Untested fix. I'm sure this started with r243611. The problem is that gsi_remove updates gsi to the next statement, not previous as would be needed in this case. If removing the last stmt in a bb, that means it will be the only removed stmt from that bb (which is wrong), if there is some stmt after it, it will just process it twice (which shouldn't have any visible effect). Now, the -fcompare-debug failure is if the bb with -g ends with debug stmt(s), and before that there is ASAN_MARK (POISON, ) and before that at least another one without a call or ASAN_CHECK or asm in between.