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

           Summary: "might be clobbered by ‘longjmp’" diagnostic for
                    unmodified variable
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: a...@gnu.org


Created attachment 23939
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23939
preprocessed input

% uname -a
Linux hush 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux
% gcc-4.6 --version
gcc-4.6 (Debian 4.6.0-2) 4.6.1 20110329 (prerelease)
Copyright (C) 2011 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.
% cat foo.c
#include <setjmp.h>

jmp_buf env;
void foo(int);

int bar(int r, int var)
{
  if (var)
    return r;
  if (setjmp(env) == 0)
    foo(r);
  return 0;
}
% gcc-4.6 -Wall -Wextra -O2 -c foo.c
foo.c: In function ‘bar’:
foo.c:6:13: warning: argument ‘r’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Wclobbered]

If I understand this message correctly, GCC is warning me that "r" might be
reset to the value it had before calling setjmp().  However, I never changed
the value of "r", so I don't think this warning should be emitted.

Note that removing the "if (var) return r;" lines makes the warning go away.

Reply via email to