https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90516
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to matszpk from comment #0) > I encountered that bug when I trying to test some program that have bug: a > missing return in loading file function that code was embraced by > try...catch. Due to this bug and enabled optimization's flags program aborts > due to double free of the memory and it was strange behaviour of this > function. Because the program has a bug and its behaviour is undefined. > Later, I wrote sample program that load some string from file and doing > nothing this same bug (missing return) with code embraced by try..catch. If > program was compiled with optimizations flags (-O3) then and if file was > exist and then program print out exception in by statement in catch clause > (just run clause) with like: 'Exception at loading: basic_ios::clear: > iostream error'. The program has undefined behaviour. The only return statement in the function is the one in the catch block, so it looks like GCC is deciding to run that code unconditionally, because there's no other valid way to return from the function. You should pay attention to the warning and fix the code.