Mail Archives: djgpp/1997/03/06/04:57:21
C:\AM>type _.cc
#include<std.h>
#include<stdio.h>
#include<setjmp.h>
int Z(int nargs,char**arg){char*T,U[128]; int j=0; jmp_buf bad;
T=nargs>=2?arg[1]:".";
if(j<6) if(setjmp(bad)) {j++; goto XX;}
strcpy(U,T);
XX: return 1;}
C:\AM>gcc _.cc -Wall -c -O2
_.cc: In function `int Z(int, char **)':
_.cc:4: warning: variable `char * T' might be clobbered by `longjmp' or `vfork'
In this program, where is the risk that longjmp may `clobber' T? This warning
goes away if I remove `strcpy(U,T);'. OK, gcc doesn't know what strcmp() does,
and has to behave as if strcpy() called longjmp() and used every function and
global variable in the program. But DJGPP\INCLUDE\STRING.H declares strcpy()
as `char * strcpy(char *_s1, <<<const>>> char *_s2);', and T is local to Z(),
therefore strcpy() can't alter T (although it may alter *T). Nothing else that
mentions T is in the range jumped over by the setjmp statement.
If the risk is only from vfork(), this should be stated separately, and
there should be an option to suppress checking for clobbering by vfork().
- Raw text -