From: "Anthony.Appleyard" Organization: Materials Science Centre To: DJGPP AT delorie DOT com Date: Fri, 13 Mar 1998 09:16:45 GMT Subject: Clobbered Reply-to: Anthony DOT Appleyard AT umist DOT ac DOT uk Message-ID: <57D90ADC@fs2.mt.umist.ac.uk> Precedence: bulk What the rules for deciding whether longjmp may `clobber' a particular local variable or a `*this'? (I never use vfork().) For example, the function hereinunder (part of a text editor that I wrote and often use) causes these two warnings when compiled with -O2:- (1) macros.cc:579: warning: variable `int b' might be clobbered by `longjmp' or `vfork' (2) macros.cc:579: warning: variable `int nn' might be clobbered by `longjmp' or `vfork' Of three local variables involved, the warning seems inappropriate:- : is set or altered once only, completely before any part of the longjmp apparatus occurs. What is the compiler talking about at (2)?? : O.K. I do alter b if longjmp occurs. But that is intended, so that the instructions after label BAD: can tell whether control is there because of a longjmp(). : is altered after the call of setjmp() but I get no `clobbered' warning. //// Breakin() == 1 if the user is pressing ctrl-alt-leftshift /*-----*/ void macro::operator()(val N/*=val(1,0)*/,int r/*=0*/){(r=r);/***/ int b=0,nn=N.n==_int?N.i:1; strings*S,*T; val *p; int i,n; macstep*A; macrinfo MI,*oldmi=mi; mi=&MI; G(); jmp_buf*oldbad=bad,failed; bad=&failed; if(setjmp(*bad)) {b=1; goto BAD;} if((n=nvars)) {p=mi->stack=new val[mi->nvars=n]; for(i=0;i16) {Moan="macro calls >16 deep"; goto BAD;} for(i=0;jump=0,Breakin()?0:inext){ MI.rec=1; jump=0; (*A)(); /* this function calls longjmp() */ mi=&MI; if(MI.rec) MI.prevstep=A; if(Breakin()) goto BAD;} BAD: for(i=0;invars;i++) mi->stack[i].del(); T=MI.delenda; while((S=T)) {T=S->next; delete S->s; delete S;} macdepth--; mi=oldmi; bad=oldbad; if(b) MOAN(Moan); /* this macro calls longjmp() */ }