Mail Archives: djgpp/1998/03/17/18:45:19
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:-
> Please post a minimal complete source that can be compiled and
> reproduces the warning about clobbering.
This program when compiled with -O2:-
#include <stdio.h>
#include <setjmp.h>
int driveexists(char T){return T;}
int drive_is_empty(char T){return T;}
/*-----*/
main(int nargs,char**arg){
int i,n; char*T,*U=0; jmp_buf emacserror,*bad;
T=nargs>=2?arg[1]:".";
bad=&emacserror; if(setjmp(*bad)) exit(1);
n=strlen(T); for(i=0;i<n;i++) if(T[i]=='['?:T[i]==']') {T="."; break;}
if(*T) if(T[1]==':') if(!driveexists(*T)?:drive_is_empty(*T)?1:0) *T=0;
strcpy(U,T);}
causes this warning:-
_.cc: In function `int main(int, char **)':
_.cc:7: warning: variable `char * T' might be clobbered by `longjmp' or `vfork'
This program when compiled with -O2:-
#include <stdio.h>
#include <setjmp.h>
int driveexists(char T){return T;}
int drive_is_empty(char T){return T;}
/*-----*/
main(int nargs,char**arg){
int i,n; volatile char*T; char*U=0; jmp_buf emacserror,*bad;
T=nargs>=2?arg[1]:".";
bad=&emacserror; if(setjmp(*bad)) exit(1);
n=strlen(T); for(i=0;i<n;i++) if(T[i]=='['?:T[i]==']') {T="."; break;}
if(*T) if(T[1]==':') if(!driveexists(*T)?:drive_is_empty(*T)?1:0) *T=0;
strcpy(U,T);}
with *T declared volatile causes these three warnings:-
_.cc: In function `int main(int, char **)':
_.cc:10: warning: passing `volatile char *' as argument 1 of
`strlen(const char *)' discards volatile
_.cc:12: warning: passing `volatile char *' as argument 2 of
`strcpy(char *, const char *)' discards volatile
_.cc:7: warning: variable `volatile char * T' might be clobbered by `longjmp'
or `vfork'
- Raw text -