From: "A.Appleyard" Organization: Materials Science Centre To: DJGPP AT DELORIE DOT COM Date: Thu, 6 Mar 1997 09:50:35 GMT Subject: gcc -O2 paranoia re `variable may be clobbered by longjmp()' Message-ID: <41F045F68D5@fs2.mt.umist.ac.uk> C:\AM>type _.cc #include #include #include 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, <<>> 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().