https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94671
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Well, the compiler shouldn't optimize away the allocation and not the deallocation or vice versa, it needs to either optimize away allocation and all corresponding deallocations, or none of that. There were some bugs on the GCC side, but 20200225 snapshot is very old, you should try something newer, last related fix is from 4 days ago.