When a function contains a call to longjmp(), some variables give the
warning
variable 'ptr' might be clobbered by 'longjmp' or 'vfork'
How to avoid this warning? In earlier versions of gcc, it was possible to
write
(void)&ptr;
in order to force ptr on the stack, where it would be unaffected by strange
behaviour of longjmp(). This doesn't work any more with gcc-4.0.
$ gcc -v
Using built-in specs.
Target: powerpc-apple-darwin7.8.0
Configured with: /Users/bruno/data/work/gcc-4.0.0-20050410/configure
--prefix=/Volumes/UserData/experimental-macos --enable-shared
--enable-version-specific-runtime-libs --enable-languages=c,c++
Thread model: posix
gcc version 4.0.0 20050410 (prerelease)
$ gcc -W -O -c bug.c
bug.c: In function 'lisp_completion':
bug.c:261: warning: variable 'array' might be clobbered by 'longjmp' or 'vfork'
bug.c:270: warning: variable 'ptr' might be clobbered by 'longjmp' or 'vfork'
bug.c:291: warning: variable 'ptr1' might be clobbered by 'longjmp' or 'vfork'
Expected:
$ gcc -W -O -c bug.c
bug.c: In function 'lisp_completion':
bug.c:291: warning: variable 'ptr1' might be clobbered by 'longjmp' or 'vfork'
--
Summary: how to force a variable into the stack?
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bruno at clisp dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.8.0
GCC host triplet: powerpc-apple-darwin7.8.0
GCC target triplet: powerpc-apple-darwin7.8.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21160