www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/21/10:33:23

Date: Thu, 21 Mar 1996 17:26:50 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
Cc: DJGPP AT delorie DOT com
Subject: Re: When and how does longjmp() `clobber' variables?
In-Reply-To: <A8BE871245@fs2.mt.umist.ac.uk>
Message-Id: <Pine.SUN.3.91.960321172112.25106R-100000@is>
Mime-Version: 1.0

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 <filename> -c -g -Wall', getting no fault remarks or
> cautions or warnings. But today I compiled it with `gcc <filename> -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? 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019