The test for emitting a warning about "variables that might be clobbered by a
call to longjmp or vfork" is overly pessimistic (unless I miss something from
the C89/C99 standards).

In my opinion, the following code fragment should not get the warning, but it
does when compiled with `gcc -O -W':
<code>
#include <setjmp.h>

extern int f(void);
extern int g(int);
extern jmp_buf jb;

int f(void)
{
  int j;

  j = 0;
  if( !setjmp(jb) ) {
    g(j);
  }
  else {
    j = -1;
  }

  return j;
}
</code>

I have also other variants that get the warning without deserving it (IMO).

Here is one relevant paragraph from ISO 9899 7.13.2.1:

<C99-quote>All accessible objects have values, and all other components of the
abstract machine have state, as of the time the longjmp function was called,
except that the values of objects of automatic storage duration that are local
to the function containing the invocation of the corresponding setjmp macro
that do not have volatile-qualified type and have been changed between the
setjmp invocation and longjmp call are indeterminate.</C99-quote>

Feel free to contact me (I could try to contribute, at least for providing more
test programs).

Thanks for your great work!

PS: the warning code in is gcc/function.c, which is why I've guessed about the
component.


-- 
           Summary: spurious warning about clobbered variables w.r.t.
                    longjmp
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvilleneuve at kronos dot com
  GCC host triplet: i386-redhat-linux


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

Reply via email to