Date: Thu, 21 Mar 1996 17:26:50 +0200 (IST) From: Eli Zaretskii To: "A.Appleyard" Cc: DJGPP AT delorie DOT com Subject: Re: When and how does longjmp() `clobber' variables? In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 21 Mar 1996, A.Appleyard wrote: > I have a big Gnu C++ program (an Emacs-type text editor) in several files, > which I compile with `gcc -c -g -Wall', getting no fault remarks or > cautions or warnings. But today I compiled it with `gcc -c -g -O3', > and got a mass of warnings of this type:- If you don't tell gcc to optimize (even just -O) it doesn't invoke some of the code that checks for certain potential problems. For instance, you will never see warnings about unused variables unless you compile with -O. It is advisable to include -O at least once just to gain the extra safety net. As in gcc -O and -g don't contradict, you should IMHO always do that. > main.cc: In function `int main(int, char **)': > main.cc:33: warning: variable `class buffer * C' might be clobbered by > `longjmp' or `vfork' I'd imagine that if you use longjmp in certain circumstances, some of the destructors for variables that are on the parts of the stack which longjmp unwinds aren't called. That's why the exceptions were introduced into C++, right?