http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161



Thorsten Glaser <tg at mirbsd dot org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |tg at mirbsd dot org



--- Comment #4 from Thorsten Glaser <tg at mirbsd dot org> 2012-09-29 22:25:14 
UTC ---

Confirmed, happens in mksh now (but not with 4.6 or 4.7), reduced testcase:



tg@zigo:~/b/mksh-40.9.20120630 $ /usr/lib/gcc-snapshot/bin/gcc --version        

gcc (Debian 20120915-1) 4.8.0 20120915 (experimental) [trunk revision 191353]

Copyright (C) 2012 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



tg@zigo:~/b/mksh-40.9.20120630 $ /usr/lib/gcc-snapshot/bin/gcc -O2 -Wextra -c

t.c                               

t.c: In function 'hereinval':

t.c:12:27: warning: argument 'content' might be clobbered by 'longjmp' or

'vfork' [-Wclobbered]

 int hereinval(const char *content, int sub, char **resbuf) {

                           ^

tg@zigo:~/b/mksh-40.9.20120630 $ cat t.c

#include <setjmp.h>

#include <string.h>

struct source {

        int foo;

        const char *str;

} *source = NULL;

jmp_buf jb;

extern char *evalstr(void);

extern struct source *pushs(void);

extern void newenv(void);

extern void quitenv(void);

int hereinval(const char *content, int sub, char **resbuf) {

        const char *ccp;

        struct source *s, *osource;



        osource = source;

        newenv();

        if (setjmp(jb)) {

                source = osource;

                quitenv();

                return (-2);

        }

        if (sub) {

                s = pushs();

                s->str = content;

                source = s;

                /* ... */

                ccp = evalstr();

                source = osource;

        } else

                ccp = content;



        *resbuf = strdup(ccp);

        return (0);

}

Reply via email to